Closed bjhomer closed 3 months ago
Have you considered moving the call to a dedicated queue? Just curious if you found issues with changing queue or if it's something that wasn't considered in the interest of getting the fix out.
Yeah, I think I would like to move it to another queue, but I was going for a smaller change in the interest of getting a fix out sooner.
And really, our events are already running on a background context… the problem is that because the main thread still needs to access that context (via -performAndWait
or -perform
), the main thread can be blocked if the context is busy doing something else on another thread.
A better solution would probably want to have two separate contexts; one for writing, and one for reading. But that seems quite a bit more complex than what I have time to allocate to this at the moment. :)
When sending tracks events, adds a limit of 1000 events to send per batch.
There are two reasons for this:
-[TracksService sendQueuedEvents]
is being called when the timer goes off. If we fetch an unbounded number of events, it can result in the main thread hanging if there are many tracks events to send.With these changes, the UI is much less likely to hang. On my device, fetching a batch of 1000 events took only 0.03s, which is probably acceptable on the main thread. By contrast, fetching 93,000 events took 2.25s, a clearly noticeable hang. (And yes, we have a user who appears to have over 100,000 unsent events. Not sure how.)
CHANGELOG.md
if necessary.