Getting a “This application is modifying the autolayout engine from a background thread” error?

后端 未结 21 1850
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 15:52

Been encountering this error a lot in my OS X using swift:

\"This application is modifying the autolayout engine from a background thread, which can

21条回答
  •  [愿得一人]
    2020-11-22 16:29

    For me, this error message originated from a banner from Admob SDK.

    I was able to track the origin to "WebThread" by setting a conditional breakpoint.

    Then I was able to get rid of the issue by encapsulating the Banner creation with:

    dispatch_async(dispatch_get_main_queue(), ^{
       _bannerForTableFooter = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];
       ...
    }
    

    I don't know why this helped as I cannot see how this code was called from a non-main-thread.

    Hope it can help anyone.

提交回复
热议问题