Skip to content

Processing under the main thread hangs the UI #2107

Description

@jesus-mg-ios

Describe the bug
I'm investigating another bug, but trying some recommendations from yours, like using sk1 and enabling log level to debug, I find that the application crashes by memory or hangs the UI.

  1. Environment

    1. Platform: iOS
    2. SDK version: 4.14.3
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): Which SDK uses by default (I think is SK1 right now)
    4. OS version: x.x.x
    5. Xcode version: 14.1.0
    6. How widespread is the issue. Percentage of devices affected. We don't know because depends on transactions.
  2. Debug logs:
    logsRevenuecat.zip

  3. Steps to reproduce:

The bug is reproduced when the SDK starts to process transactions. I think that part of the process is done inside of the Main actor, using the main thread for that. When It processes only a few transactions, all is working as expected, but when the number of transactions is high, the UI hangs, and memory increases exponentially.

  1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

image

StoreKit1Wrapper.swift:128
image

I don't know if it makes sense, but maybe there's a way to use a background thread to process them or maybe create a global actor that uses other queues (custom if it's possible). Also, processing a great number of transactions could take time, maybe there's a way to process a prefix or suffix of 50, ordering them by date && success result and don't communicate the rest of them directly to back doing batches.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions