googleads / googleads-mobile-ios-examples

googleads-mobile-ios
Apache License 2.0
956 stars 807 forks source link

RewardedAd - Main thread blocked by synchronous property query on not-yet-loaded property [MULTIPLE_REASON] for HTTP(S) asset Issue #390

Closed eliakorkmaz closed 6 months ago

eliakorkmaz commented 9 months ago

Hello,

I am using the SDK with version 10.14.0

When i implement the Google Rewarded Ad and try to load it GADRewardedAd instance, I get these error logs

Main thread blocked by synchronous property query on not-yet-loaded property (assetProperty_Tracks) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (NaturalSize) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (PreferredTransform) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (EstimatedDataRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (NominalFrameRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

I tried the example app, basic structure, ViewController, and one ad instance loading, still same error logs happening

How does it affect my application?

When I try to implement a reward mechanism, if I have to dismiss a UIViewController, it can't get dismissed because of the main thread somehow gets blocked all the time, so this issue makes the Rewarded Ad unit useless.

XCode Version: Version 15.1 (15C65) Device Version: iOS 17.0.3 (21A360)

I also tried Interstitial Ad units, as I played a bunch of ad units, The GADRewardedAd unit is the only unit that generated this error

And I tried loading the ad unit with a background thread, no luck

[NOTE]

I am using SPM for Google Mobile Ads, so package's url is https://github.com/googleads/swift-package-manager-google-mobile-ads/issues but I am also facing this issue with in these example's code, so i opened issue here, i can also create another issue in that SPM package

inastatkic commented 8 months ago

I would like to rise the issue. +1 Native Ads

Main thread blocked by synchronous property query on not-yet-loaded property (assetProperty_Tracks) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (NaturalSize) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (PreferredTransform) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (EstimatedDataRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (NominalFrameRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

SwiftUIDemo using SPM.

Google Mobile Ads SDK version: 10.14.0 Xcode Version 15.1 (15C65) iPhone 12 Pro iOS 17.2.1

Step to reproduce:

Select Native from the list with Ad that contains a video asset

Along the way: Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>

ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=8347, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}

Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}>

ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=8348, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}

Zamods commented 8 months ago

Hello,

I am using the SDK with version 10.14.0

When i implement the Google Rewarded Ad and try to load it GADRewardedAd instance, I get these error logs

Main thread blocked by synchronous property query on not-yet-loaded property (assetProperty_Tracks) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (NaturalSize) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (PreferredTransform) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (EstimatedDataRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.
Main thread blocked by synchronous property query on not-yet-loaded property (NominalFrameRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

I tried the example app, basic structure, ViewController, and one ad instance loading, still same error logs happening

How does it affect my application?

When I try to implement a reward mechanism, if I have to dismiss a UIViewController, it can't get dismissed because of the main thread somehow gets blocked all the time, so this issue makes the Rewarded Ad unit useless.

XCode Version: Version 15.1 (15C65) Device Version: iOS 17.0.3 (21A360)

I also tried Interstitial Ad units, as I played a bunch of ad units, The GADRewardedAd unit is the only unit that generated this error

And I tried loading the ad unit with a background thread, no luck

[NOTE]

I am using SPM for Google Mobile Ads, so package's url is https://github.com/googleads/swift-package-manager-google-mobile-ads/issues but I am also facing this issue with in these example's code, so i opened issue here, i can also create another issue in that SPM package

I get same console output on reward ads but after timer finishes i can dismiss the UIViewController.

I load it like this:

YourView{
}.onAppear{
Task{
     rewardCoordinator.loadAd()
  }
}

And present like this:

rewardCoordinator.showAd(from: adViewControllerRepresentable.viewController){reward in 
// handle the reward
}

My Reward coordinator

RewardAdCoordinator

class RewardedAdCoordinator: NSObject, GADFullScreenContentDelegate {
    let adUnitID: String
    var rewardedInterstitialAd: GADRewardedInterstitialAd?
    init(adUnitID: String = "ca-app-pub-3940256099942544/6978759866", rewardedInterstitialAd: GADRewardedInterstitialAd? = nil) {
        self.adUnitID = adUnitID
        self.rewardedInterstitialAd = rewardedInterstitialAd
    }
    func loadAd() {
        GADRewardedInterstitialAd.load(
            withAdUnitID: adUnitID, request: GADRequest()
        ) { ad, error in
            self.rewardedInterstitialAd = ad
            self.rewardedInterstitialAd?.fullScreenContentDelegate = self
        }
    }

    func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
        rewardedInterstitialAd = nil
    }

    func showAd(
        from viewController: UIViewController,
        userDidEarnRewardHandler completion: @escaping (Int) -> Void
    ) {
        guard let rewarded = rewardedInterstitialAd else {
            return print("Ad wasn't ready")
        }

        rewarded.present(fromRootViewController: viewController) {
            let reward = rewarded.adReward
            print("Reward amount: \(reward.amount)")
            completion(reward.amount.intValue)
        }
    }
}
NVentimiglia commented 8 months ago

@Zamods

This is my first time seeing an error like this. Is this Swift UI by chance?

Can you please file a request here and I will get the right person to help you.

Zamods commented 8 months ago

@NVentimiglia Thanks, I will file a request at provided link later tonight. Yes, i'm using SwiftUI, app is designed to be single page app and i display rewarded ad by explicit user impression.

However, after trial and error i found out if ad is loaded right after getting user consent through GoogleMobileAdsConsentManager.shared.gatherConsent( from: formViewControllerRepresentable.viewController ) then starting sdk through GADMobileAds.sharedInstance().start(completionHandler: nil) in onAppear() view modifier then i would get such error else it's ok at-least as per swiftUI sample project.

abbasnaqvi200 commented 2 months ago

Same Issue +1

GoogleMobile SDK Version : 11.7.0 XCode Version :- 15.3

let nativeOptions = GADNativeAdViewAdOptions() nativeOptions.preferredAdChoicesPosition = .topRightCorner

let videoOptions = GADVideoOptions() videoOptions.startMuted = false videoOptions.customControlsRequested = true

let aspectRatioOption = GADNativeAdMediaAdLoaderOptions() aspectRatioOption.mediaAspectRatio = .any

let adLoader = GADAdLoader(adUnitID: adUnitID, self: vc,adTypes: [.native], options: [aspectRatioOption,videoOptions,nativeOptions]) adLoader.delegate = self adLoader.load(GADRequest())

**

Main thread blocked by synchronous property query on not-yet-loaded property (assetProperty_Tracks) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (NaturalSize) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (PreferredTransform) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (EstimatedDataRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

Main thread blocked by synchronous property query on not-yet-loaded property (NominalFrameRate) for HTTP(S) asset. This could have been a problem if this asset were being read from a slow network.

**