fbsamples / audience-network

Open source projects to demonstrate SDK and sample code usages and integration, and to collaborate and support peers in this community.
https://developers.facebook.com/docs/audience-network
Other
319 stars 370 forks source link

UI API called from background thread #88

Closed Izzyjm closed 3 years ago

Izzyjm commented 5 years ago

Does anyone know why once I call the [self.adView loadAd] method on ios it gives me this warning ?

screen shot 2019-02-27 at 11 01 31 pm

andrewliu-code commented 5 years ago

Hi @Izzyjm, could you share the SDK version and a sample app for us to look into it since I cannot reproduce the same issue. I did not see the same warning while calling loadAd for banner ad.

Izzyjm commented 5 years ago

@andrewliu-code hello it is here https://github.com/Izzyjm/FAN-banner-implementation-BUG-

SDK version 5.2.0

could you confirm once you reproduce

andrewliu-code commented 5 years ago

Hi @Izzyjm, I was running your sample app and having Pause on issues turned on for Runtime API Checking. Xcode didn't detect anything running on the background thread and pause the app. Maybe you can provide more information so I could try to simulate your debug environment and reproduce it

Izzyjm commented 5 years ago

@andrewliu-code that’s weird I wonder why it’s not showing up for you , all I did was create a new empty project in Xcode and then implement it like it is in the project that I shared , also what is “pause on issues”?

andrewliu-code commented 5 years ago

Check out this video, https://developer.apple.com/videos/play/wwdc2017/406/

Izzyjm commented 5 years ago

hey @andrewliu-code recently I noticed my android log console print this out "You don't call AudienceNetworkAds.initialize(). Some functionality may not work properly" but no where in the documentation did it ever mention to make this call so how will developers know to include this ?

whswee-newswav commented 5 years ago

Having the same issue when calling loadAd

self.nativeAd = [[FBNativeAd alloc] initWithPlacementID:[self placementID]]; [self.nativeAd setDelegate:self]; [self.nativeAd loadAd];

Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 10678, TID: 2580581, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0

MayueCastbox commented 5 years ago

Same issue here, it can be also reproduced with sample project.

One line summary of the issue here "UI API called from background thread" warning is produced after loading facebook ad very first time in app life cycle.

Device model and OS Version:

iPhone XR iOS 12.2

Xcode Version:

Version 10.2.1 (10E1001)

Observed behavior:

There got the warning in console, and also main thread was blocked for a while, as UI wasn't responsible.

Evidence:

2019-06-11 14:14:30.869504+0800 [MoPub][GoogleAdMobAdapterConfiguration] Google Mobile Ads SDK initialized succesfully. 2019-06-11 14:14:32.175689+0800 [MoPub][MoPub] SDK initialized and ready to display ads. Initialized adapters: FacebookAdapterConfiguration: Adapter version 5.3.2.0, SDK version 5.3.2 GoogleAdMobAdapterConfiguration: Adapter version 7.44.0.0, SDK version 7.44.0

2019-06-11 14:14:56.525316+0800 [MoPub][MPNativeAdRequest][574890e4c790474993693749cfd2b449] Attempting to load ad 2019-06-11 14:14:57.348661+0800
[MoPub][MPNativeAdRequest] Received data from MoPub to construct native ad. 2019-06-11 14:14:57.350067+0800 Castbox[33648:6905860] [MoPub][MPNativeAdRequest] Looking for custom event class named MPGoogleAdMobNativeCustomEvent. 2019-06-11 14:14:57.355336+0800 To get test ads on this device, set: request.testDevices = @[ @"437a4d86ef1833e08306bceafa2411fd" ]; 2019-06-11 14:14:57.356158+0800
[MoPub][MPGoogleAdMobNativeCustomEvent] Google Mobile Ads SDK initialized succesfully. 2019-06-11 14:14:58.462438+0800
[MoPub][MPNativeAdRequest] Received data from MoPub to construct native ad. 2019-06-11 14:14:58.463207+0800
[MoPub][MPNativeAdRequest] Looking for custom event class named FacebookNativeCustomEvent. 2019-06-11 14:14:58.464860+0800 [MoPub][FacebookNativeCustomEvent] Loading Facebook native ad

================================================================= Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 33648, TID: 6906198, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libobjc.A.dylib 0x000000018c9c76f4 + 56 5 CoreMotion 0x0000000193111638 CoreMotion + 292408 6 CoreMotion 0x0000000193111b68 CoreMotion + 293736 7 CoreMotion 0x0000000193111a78 CoreMotion + 293496 8 CoreMotion 0x000000019313f8a8 CoreMotion + 481448 9 CoreMotion 0x000000019313f8ec CoreMotion + 481516 10 CoreFoundation 0x000000018d75378c + 28 11 CoreFoundation 0x000000018d753074 + 276 12 CoreFoundation 0x000000018d74e368 + 2276 13 CoreFoundation 0x000000018d74d764 CFRunLoopRunSpecific + 452 14 CoreFoundation 0x000000018d74e498 CFRunLoopRun + 84 15 CoreMotion 0x000000019313f280 CoreMotion + 479872 16 libsystem_pthread.dylib 0x000000018d3cd920 + 132 17 libsystem_pthread.dylib 0x000000018d3cd87c _pthread_start + 48 18 libsystem_pthread.dylib 0x000000018d3d5dcc thread_start + 4 2019-06-11 14:14:58.478666+0800 Castbox[33648:6906198] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 33648, TID: 6906198, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0 Backtrace: 4 libobjc.A.dylib 0x000000018c9c76f4 + 56 5 CoreMotion 0x0000000193111638 CoreMotion + 292408 6 CoreMotion 0x0000000193111b68 CoreMotion + 293736 7 CoreMotion 0x0000000193111a78 CoreMotion + 293496 8 CoreMotion 0x000000019313f8a8 CoreMotion + 481448 9 CoreMotion 0x000000019313f8ec CoreMotion + 481516 10 CoreFoundation 0x000000018d75378c + 28 11 CoreFoundation 0x000000018d753074 + 276 12 CoreFoundation 0x000000018d74e368 + 2276 13 CoreFoundation 0x000000018d74d764 CFRunLoopRunSpecific + 452 14 CoreFoundation 0x000000018d74e498 CFRunLoopRun + 84 15 CoreMotion 0x000000019313f280 CoreMotion + 479872 16 libsystem_pthread.dylib 0x000000018d3cd920 + 132 17 libsystem_pthread.dylib 0x000000018d3cd87c _pthread_start + 48 18 libsystem_pthread.dylib 0x000000018d3d5dcc thread_start + 4