AppLovin / AppLovin-MAX-SDK-iOS

Other
91 stars 72 forks source link

-[UIView gestureRecognizers], -[UIView removeGestureRecognizer:], -[UIView removeFromSuperview] Main Thread Checker: UI API called on a background thread #363

Closed Hachiware-05-01 closed 1 week ago

Hachiware-05-01 commented 2 months ago

MAX SDK Version

12.6.1

Device/Platform Info

iOS 13 ~ 17

Current Behavior

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView gestureRecognizers]
PID: 5272, TID: 39395, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   AppLovinSDK                         0x00000001089a8290 -[UIView(ALUtils) al_removeAllGestureRecognizers] + 48
5   AppLovinSDK                         0x00000001088b410c -[ALNativeAd unregisterViewsForInteraction] + 216
6   AppLovinSDK                         0x00000001088b3a44 -[ALNativeAd destroy] + 20
7   AppLovinSDK                         0x00000001088fcfa4 -[ALAppLovinMediationAdapter destroy] + 80
8   AppLovinSDK                         0x0000000108992970 __36-[ALMediationAdapterWrapper destroy]_block_invoke + 56
9   AppLovinSDK                         0x0000000108993000 __67-[ALMediationAdapterWrapper runOperationWithTag:forAdFormat:block:]_block_invoke + 152
10  AppLovinSDK                         0x00000001088a142c -[ALBlockTask run] + 36
11  AppLovinSDK                         0x000000010895f4c0 -[ALTask main] + 348
12  libdispatch.dylib                   0x00000001095a80f0 _dispatch_call_block_and_release + 24
13  libdispatch.dylib                   0x00000001095a993c _dispatch_client_callout + 16
14  libdispatch.dylib                   0x00000001095bd6f4 _dispatch_root_queue_drain + 940
15  libdispatch.dylib                   0x00000001095be068 _dispatch_worker_thread2 + 256
16  libsystem_pthread.dylib             0x0000000106e677d8 _pthread_wqthread + 224
17  libsystem_pthread.dylib             0x0000000106e665d4 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView removeGestureRecognizer:]
PID: 5272, TID: 39395, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   AppLovinSDK                         0x00000001089a82f4 -[UIView(ALUtils) al_removeAllGestureRecognizers] + 148
5   AppLovinSDK                         0x00000001088b410c -[ALNativeAd unregisterViewsForInteraction] + 216
6   AppLovinSDK                         0x00000001088b3a44 -[ALNativeAd destroy] + 20
7   AppLovinSDK                         0x00000001088fcfa4 -[ALAppLovinMediationAdapter destroy] + 80
8   AppLovinSDK                         0x0000000108992970 __36-[ALMediationAdapterWrapper destroy]_block_invoke + 56
9   AppLovinSDK                         0x0000000108993000 __67-[ALMediationAdapterWrapper runOperationWithTag:forAdFormat:block:]_block_invoke + 152
10  AppLovinSDK                         0x00000001088a142c -[ALBlockTask run] + 36
11  AppLovinSDK                         0x000000010895f4c0 -[ALTask main] + 348
12  libdispatch.dylib                   0x00000001095a80f0 _dispatch_call_block_and_release + 24
13  libdispatch.dylib                   0x00000001095a993c _dispatch_client_callout + 16
14  libdispatch.dylib                   0x00000001095bd6f4 _dispatch_root_queue_drain + 940
15  libdispatch.dylib                   0x00000001095be068 _dispatch_worker_thread2 + 256
16  libsystem_pthread.dylib             0x0000000106e677d8 _pthread_wqthread + 224
17  libsystem_pthread.dylib             0x0000000106e665d4 start_wqthread + 8
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView removeFromSuperview]
PID: 5272, TID: 39395, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   AppLovinSDK                         0x00000001088b4258 -[ALNativeAd unregisterViewsForInteraction] + 548
5   AppLovinSDK                         0x00000001088b3a44 -[ALNativeAd destroy] + 20
6   AppLovinSDK                         0x00000001088fcfa4 -[ALAppLovinMediationAdapter destroy] + 80
7   AppLovinSDK                         0x0000000108992970 __36-[ALMediationAdapterWrapper destroy]_block_invoke + 56
8   AppLovinSDK                         0x0000000108993000 __67-[ALMediationAdapterWrapper runOperationWithTag:forAdFormat:block:]_block_invoke + 152
9   AppLovinSDK                         0x00000001088a142c -[ALBlockTask run] + 36
10  AppLovinSDK                         0x000000010895f4c0 -[ALTask main] + 348
11  libdispatch.dylib                   0x00000001095a80f0 _dispatch_call_block_and_release + 24
12  libdispatch.dylib                   0x00000001095a993c _dispatch_client_callout + 16
13  libdispatch.dylib                   0x00000001095bd6f4 _dispatch_root_queue_drain + 940
14  libdispatch.dylib                   0x00000001095be068 _dispatch_worker_thread2 + 256
15  libsystem_pthread.dylib             0x0000000106e677d8 _pthread_wqthread + 224
16  libsystem_pthread.dylib             0x0000000106e665d4 start_wqthread + 8

Expected Behavior

Main Thread Checker: Resolve UI API errors called in background threads

How to Reproduce

It can be reproduced by releasing the ViewController that implements NativeAd.

Additional Info

No response

richashukla23 commented 2 months ago

Thanks for your feedback! We will take a look and keep you posted.

nvrtdfrst commented 2 months ago

Having the same problem after upgrading to 12.6.1. Leads to an abrupt crash. It seems to be coming from the method "destroyAd" from my MANativeAdLoader instance. I tried wrapping the call in a block that executes on the main thread but it did not solve the problem. My stacktrace:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIView removeFromSuperview]
PID: 442, TID: 10597, Thread name: (none), Queue name: com.apple.root.user-initiated-qos, QoS: 25
Backtrace:
4   Loud Alarm Clock                    0x00000001023de658 -[ALGoogleMediationAdapter destroy] + 512
5   AppLovinSDK                         0x0000000103ca49d4 __36-[ALMediationAdapterWrapper destroy]_block_invoke + 56
6   AppLovinSDK                         0x0000000103ca5064 __67-[ALMediationAdapterWrapper runOperationWithTag:forAdFormat:block:]_block_invoke + 152
7   AppLovinSDK                         0x0000000103bb346c -[ALBlockTask run] + 36
8   AppLovinSDK                         0x0000000103c71524 -[ALTask main] + 348
9   libdispatch.dylib                   0x0000000104e10028 _dispatch_call_block_and_release + 24
10  libdispatch.dylib                   0x0000000104e11860 _dispatch_client_callout + 16
11  libdispatch.dylib                   0x0000000104e23bf0 _dispatch_root_queue_drain + 688
12  libdispatch.dylib                   0x0000000104e24414 _dispatch_worker_thread2 + 208
13  libsystem_pthread.dylib             0x000000020a1e0b14 _pthread_wqthread + 224
14  libsystem_pthread.dylib             0x000000020a1e067c start_wqthread + 8
Lorenzo45 commented 2 months ago

@nvrtdfrst thanks for the update. We have a fix for this going out in the next SDK release (internal ticket). We'll let you know when the fix is live.

nvrtdfrst commented 1 month ago

@Lorenzo45 Absolutely, thanks for addressing the issue so quickly!

Lorenzo45 commented 1 week ago

Hi @nvrtdfrst - we released a fix for this in iOS SDK 13.0.0+. Thanks for reporting the issue!