Skip to content

[TVOCall dealloc] halts the main thread for almost 1 second #118

@nalexn

Description

@nalexn

Description

We've been hunting down app hangs in our app using Xcode metrics and other third-party tools, and identified when TVOCall is released the main thread is being held synchronously for almost 1 second.
We've tried a workaround with retaining + releasing the call instance from a background queue, but this approach resulted in spontaneous crashes, so this didn't work.

Here is the stack trace to where the wait happens, resulting in the app hang:

Screenshot 2023-09-04 at 22 32 21

Steps to Reproduce

You can measure the delay yourself by moving the code that releases the call into an autoreleasepool and comparing the timestamps before and after that block.

I did notice the delay is longer for established calls (after both parties start hearing each other). Incoming or outgoing doesn't seem to make any difference in the delays.

We release the call instance shortly after func callDidDisconnect(call: Call, error: Error?) is called by the SDK.
We also tried artificially retaining the instance for several more seconds (DispatchQueue.main.asyncAfter) - and still the call deallocation was hanging the app for the same period of time (but later).

Expected Behavior

The TVOCall should not block the main thread upon deallocation.

Actual Behavior

Main thread is blocked for ~1 second every time the TVOCall is deallocated

Reproduces How Often

100%

Voice iOS SDK

6.7.0 SPM

Xcode

14.3.1

iOS Version

Various

iOS Device

Various

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions