Main Thread Checker: UI API called on a background thread

1,003 views
Skip to first unread message

Logan Wang

unread,
Aug 19, 2019, 2:56:41 AM8/19/19
to Interactive Media Ads SDK

[reports] Main Thread Checker: UI API called on a background thread: -[WKWebView evaluateJavaScript:completionHandler:]

PID: 20894, TID: 6519267, Thread name: (none), Queue name: com.apple.avfoundation.avasset.completionsQueue, QoS: 0

Backtrace:

4   GoogleInteractiveMediaAds           0x00000001048edce8 -[IMAWKWebView evaluateJavaScript:completionHandler:] + 220

5   GoogleInteractiveMediaAds           0x00000001048eeb4c -[IMAWebViewDispatcher sendMessage:] + 572

6   GoogleInteractiveMediaAds           0x00000001048ef768 -[IMAJavaScriptSession sendMessage:] + 140

7   GoogleInteractiveMediaAds           0x00000001048e82c4 -[IMAVideoDisplayWrapper sendMessageWithType:messageData:onChannel:] + 172

8   GoogleInteractiveMediaAds           0x00000001048e7e5c -[IMAVideoDisplayWrapper videoDisplay:didReceiveError:] + 280

9   GoogleInteractiveMediaAds           0x00000001048def44 -[IMAAVPlayerVideoDisplay assetLoader:didReceiveError:] + 132

10  GoogleInteractiveMediaAds           0x00000001048dca24 __32-[IMAAVAssetLoader loadMetadata]_block_invoke + 604

11  libdispatch.dylib                   0x000000010681f1fc _dispatch_call_block_and_release + 32

12  libdispatch.dylib                   0x000000010682077c _dispatch_client_callout + 20

13  libdispatch.dylib                   0x0000000106828a34 _dispatch_lane_serial_drain + 716

14  libdispatch.dylib                   0x000000010682973c _dispatch_lane_invoke + 412

15  libdispatch.dylib                   0x0000000106833474 _dispatch_workloop_worker_thread + 1172

16  libsystem_pthread.dylib             0x00000001c5b25a98 _pthread_wqthread + 308

17  libsystem_pthread.dylib             0x00000001c5b2bdc4 start_wqthread + 4

Logan Wang

unread,
Aug 19, 2019, 2:58:27 AM8/19/19
to Interactive Media Ads SDK
SDK: iOS 3.9.2

IMA SDK

unread,
Aug 19, 2019, 6:08:59 AM8/19/19
to logan...@glowing.com, ima...@googlegroups.com

Hi Logan,

Thank you for reaching out to us and for sharing your concern.

However, could you elaborate more or could you share some steps on how to replicate the issue that you have encountered?
I've tested the IMA SDK for iOS basic sample app and updated the SDK version to 3.9 as stated here in our Getting Started guide, and I was not able to reproduce the issue.

Let me know if you have further clarifications and I'll be glad to help.


Regards,
Sherwin Diesta
IMA SDK Team



ref:_00D1U1174p._5001UEJT9u:ref

Logan Wang

unread,
Aug 19, 2019, 6:23:04 AM8/19/19
to Interactive Media Ads SDK
The steps are very simple:

First of all, the video of the ad can't load today(I don't know why, maybe network problem). 

1. Play a video and request Ad.
2. About 8 seconds later(Ads video request timeout), I will destroy the IMAAdsManager and related ads container view;
3. Request a new ad at the beginning of the next video.
4. Several times repeated step 2-3, then I got the crash.

IMA SDK

unread,
Aug 19, 2019, 11:10:58 PM8/19/19
to logan...@glowing.com, ima...@googlegroups.com

Hi Logan,

Thank you for your response and for sharing this information.

I'm not sure how you implemented the IMAAdsManager destroy, but please note that this method together with the Ads loader contentComplete are being called during the initialization of the Ads Loader (please see the IMA SDK for iOS advance integration sample for your reference).

Hence, before making a new ad request, make sure to call these methods to set the SDK for the new ad request.




Regards,
Sherwin Diesta
IMA SDK Team



ref:_00D1U1174p._5001UEJT9u:ref

Logan Wang

unread,
Aug 19, 2019, 11:22:02 PM8/19/19
to Interactive Media Ads SDK
Hi Sherwin,

I called contentComplete after video playing finished, before the next ads request and view controller deallocated. Is it necessary to call it after AdsManager destroyed?

Regards,
Logan Wang

IMA SDK

unread,
Aug 20, 2019, 1:56:11 AM8/20/19
to logan...@glowing.com, ima...@googlegroups.com

Hi Logan,

Yes, if you're going to make a new ad request after destroying the Ad manager.
The Ads loader contentComplete will help to set up the SDK for your new ad request and will make a signal to the SDK that the content has completed.




Regards,
Sherwin Diesta
IMA SDK Team



ref:_00D1U1174p._5001UEJT9u:ref

Logan Wang

unread,
Sep 16, 2019, 1:40:01 AM9/16/19
to Interactive Media Ads SDK
Hi,
We have received some crashes reported by Fabric, I think its related with this "Main Thread Checker", here is the crash call stack trace(I also attached the snapshot to the attachment):

Crashed: com.apple.avfoundation.avasset.completionsQueue
0  WebKit                         0x1bfbb9b7c WTFCrashWithInfo(int, char const*, char const*, int) + 20
1  WebKit                         0x1bfd49538 WebKit::CallbackMap::put(WTF::Ref<WebKit::CallbackBase, WTF::DumbPtrTraits<WebKit::CallbackBase> >&&) + 156
2  WebKit                         0x1bfd6eb58 WebKit::CallbackID WebKit::CallbackMap::put<API::SerializedScriptValue*, bool, WebCore::ExceptionDetails const&, WebKit::CallbackBase::Error>(WTF::Function<void (API::SerializedScriptValue*, bool, WebCore::ExceptionDetails const&, WebKit::CallbackBase::Error)>&&, WTF::RefPtr<WTF::RefCounter<WebKit::ProcessThrottler::BackgroundActivityCounterType>::Count, WTF::DumbPtrTraits<WTF::RefCounter<WebKit::ProcessThrottler::BackgroundActivityCounterType>::Count> > const&) + 116
3  WebKit                         0x1bfd6ea70 WebKit::WebPageProxy::runJavaScriptInMainFrame(WTF::String const&, bool, WTF::Function<void (API::SerializedScriptValue*, bool, WebCore::ExceptionDetails const&, WebKit::CallbackBase::Error)>&&) + 212
4  WebKit                         0x1bfbac3c4 -[WKWebView _evaluateJavaScript:forceUserGesture:completionHandler:] + 136
5  GoogleInteractiveMediaAds      0x103c95d1c _hidden#1424_ + 113 (__hidden#1445_:113)
6  GoogleInteractiveMediaAds      0x103c96b80 _hidden#1457_ + 94 (__hidden#1469_:94)
7  GoogleInteractiveMediaAds      0x103c9779c _hidden#1492_ + 26 (__hidden#1502_:26)
8  GoogleInteractiveMediaAds      0x103c902f8 _hidden#1157_ + 279 (__hidden#1183_:279)
9  GoogleInteractiveMediaAds      0x103c8fe90 _hidden#1149_ + 232 (__hidden#1183_:232)
10 GoogleInteractiveMediaAds      0x103c86f78 _hidden#782_ + 391 (__hidden#860_:391)
11 GoogleInteractiveMediaAds      0x103c84ab0 _hidden#738_ + 43 (__hidden#753_:43)
12 libdispatch.dylib              0x1b00e8a38 _dispatch_call_block_and_release + 24
13 libdispatch.dylib              0x1b00e97d4 _dispatch_client_callout + 16
14 libdispatch.dylib              0x1b00c4dec _dispatch_lane_serial_drain$VARIANT$armv81 + 548
15 libdispatch.dylib              0x1b00c592c _dispatch_lane_invoke$VARIANT$armv81 + 408
16 libdispatch.dylib              0x1b00cde08 _dispatch_workloop_worker_thread + 584
17 libsystem_pthread.dylib        0x1b02ca114 _pthread_wqthread + 304
18 libsystem_pthread.dylib        0x1b02cccd4 start_wqthread + 4

WX20190916-115834.png

IMA SDK

unread,
Sep 16, 2019, 4:42:53 AM9/16/19
to logan...@glowing.com, ima...@googlegroups.com
Hi Logan,

Thank you for reporting this. Let me do the best I can to assist you on this.

Could you please confirm if you are using the latest version of the SDK? Also, is the issue locally reproducible? If so, could you please provide us a test project and the steps to trigger the crash along with the ad tag that you are using? Please use the "Reply privately to author" option to share the details privately

Regards,
Teejay Pimentel
IMA SDK Team

ref:_00D1U1174p._5001UHGsnF:ref

Logan Wang

unread,
Sep 16, 2019, 10:17:14 PM9/16/19
to Interactive Media Ads SDK
Hi Teejay,

Thank you for your reply. And I'm sure we are using the latest version of the SDK. I can't reproduce it locally. The "Ad Tag" is returned by the server, so I don't know what it is.

IMA SDK

unread,
Sep 17, 2019, 1:40:37 AM9/17/19
to logan...@glowing.com, ima...@googlegroups.com
Hi Logan,

Thank you for getting back to us. 

The IMA SDK requires an ad tag that will be used to request a VAST response from an Ad server (Ad Manager/AFV/AdX). You may check this IMA Sample Tags for your reference.

With regard to the crash that you've encountered, this was previously reported by other publishers as well, and it was already raised to our Engineering team for investigation. I'll relay this information to them and get back to you the soonest they provide their feedback.

Mark Davies

unread,
Oct 7, 2019, 2:43:01 PM10/7/19
to Interactive Media Ads SDK
Hi, we are also getting many of these crashes.  Do you have a status update regarding the crash?  
Reply all
Reply to author
Forward
0 new messages