Gruveo / gruveo-ios-sdk

The Gruveo SDK for iOS and a sample project.
https://about.gruveo.com/developers/ios-sdk/
MIT License
2 stars 0 forks source link

UI API called on a background thread #7

Closed umarniz closed 6 years ago

umarniz commented 6 years ago

I am using the Gruveo SDK from React Native using my react-native-gruveo-sdk component.

As you can see in the implementation file that all calls to GruveoSDK are wrapped to run only from the main thread to ensure that a call is not made from a wrong thread on our end.

But when testing we still get this error during testing and causes our app to freeze mid way through Establishing Call.

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 10923, TID: 6054653, Thread name: AVAudioSession Notify Thread, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4   GruveoSDK                           0x00000001019ab578 -[MediaManager notifyAudioRouteChanged:] + 276
5   CoreFoundation                      0x000000018303cc3c <redacted> + 20
6   CoreFoundation                      0x000000018303c1b8 <redacted> + 428
7   CoreFoundation                      0x000000018303bf14 <redacted> + 216
8   CoreFoundation                      0x00000001830b984c <redacted> + 1408
9   CoreFoundation                      0x0000000182f72f38 _CFXNotificationPost + 384
10  Foundation                          0x00000001839e3bbc <redacted> + 68
11  AVFAudio                            0x0000000188a5894c <redacted> + 1096
12  AVFAudio                            0x0000000188a57f08 <redacted> + 1764
13  AudioToolbox                        0x0000000186d1bcc0 <redacted> + 744
14  AudioToolbox                        0x0000000186e0ea3c <redacted> + 224
15  AudioToolbox                        0x0000000186e4d754 <redacted> + 644
16  AudioToolbox                        0x0000000186e51cb4 <redacted> + 292
17  AudioToolbox                        0x0000000186e51110 <redacted> + 1496
18  AudioToolbox                        0x0000000186e5084c <redacted> + 584
19  AudioToolbox                        0x0000000186d0c2a8 <redacted> + 52
20  AudioToolbox                        0x0000000186ff3210 <redacted> + 232
21  CoreFoundation                      0x0000000183053ae8 <redacted> + 56
22  CoreFoundation                      0x0000000183053230 <redacted> + 440
23  CoreFoundation                      0x0000000183050c80 <redacted> + 2456
24  CoreFoundation                      0x0000000182f70da8 CFRunLoopRunSpecific + 552
25  AVFAudio                            0x0000000188a56424 <redacted> + 164
26  AVFAudio                            0x0000000188a80834 <redacted> + 88
27  libsystem_pthread.dylib             0x0000000182cd1220 <redacted> + 272
28  libsystem_pthread.dylib             0x0000000182cd1110 <redacted> + 0
29  libsystem_pthread.dylib             0x0000000182ccfb10 thread_start + 4

Freezes on:

img_3b392e122aef-1

I tried resuming and pausing the debugger multiple times to see where it stops:

image

artmatsak commented 6 years ago

Thanks for reporting, we're looking into this.

artmatsak commented 6 years ago

@umarniz I have emailed you a test SDK, please add that and let me know if it fixes the issue for you.

umarniz commented 6 years ago

Hi @artmatsak thank you for the response and personally emailing the new SDK. Really appreciate the support and this is why we love using Gruveo in our apps.

The original problem of the error in notifyAudioRouteChanged running on main thread has been fixed in the new SDK but the core problem of the application freezing still remains.

I see sometimes when the Gruveo screen freezes I get:

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 14224, TID: 8059774, Thread name: DecodingThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
4   WebRTC                              0x0000000105d09914 RTCIsUIApplicationActive + 56
5   WebRTC                              0x0000000105d049ec RTCSetVertexData + 90988
6   WebRTC                              0x0000000105e2c880 RTCIsUIApplicationActive + 1191844
7   WebRTC                              0x0000000106059f60 RTCIsUIApplicationActive + 3475076
8   WebRTC                              0x0000000106069288 RTCIsUIApplicationActive + 3537324
9   WebRTC                              0x0000000106069388 RTCIsUIApplicationActive + 3537580
10  WebRTC                              0x000000010604bffc RTCIsUIApplicationActive + 3417888
11  WebRTC                              0x0000000105d34778 RTCIsUIApplicationActive + 175772
12  WebRTC                              0x0000000105d3460c RTCIsUIApplicationActive + 175408
13  libsystem_pthread.dylib             0x0000000182cd1220 <redacted> + 272
14  libsystem_pthread.dylib             0x0000000182cd1110 <redacted> + 0
15  libsystem_pthread.dylib             0x0000000182ccfb10 thread_start + 4

This is something I have seen in the previous SDK too so I know this warning has existed before too but I don't get this error every time a Gruveo video call freezes.

It might be part of the problem but its not the complete problem IMO.

Some times I get no error message in the console and the Video call just freezes and the buttons become unresponsive.

In all scenarios I can see the main thread doing:

img_3b392e122aef-1

But as you can see all other threads are just waiting when I pause the debugger:

image

I have a feeling that incorrect packets are sometimes delivered over websocket causing the thread not to understand and stay stuck in a while loop, but of-course I can't make any judgement never having seen any source code and you would understand the problem best :)

Thanks!

The problem is a bit hard to reproduce but I can almost always get it when testing calls sent from web and received by iOS within 20-30 attempts.

artmatsak commented 6 years ago

Looking into it, thanks.

umarniz commented 6 years ago

This has been resolved in Gruveo 1.2