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

后端 未结 21 1668
爱一瞬间的悲伤
爱一瞬间的悲伤 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:37

    Here check out this line from the logs

    $S12AppName18ViewControllerC11Func()ySS_S2StF + 4420
    

    you can check that which function calling from the either background thread or where you are calling api method you need to call your function from the main thread like this.

    DispatchQueue.main.async { func()}
    

    func() is that function you want to call in the result of api call success or else.

    Logs Here

    This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes.
     Stack:(
        0   Foundation                          0x00000001c570ce50  + 96
        1   Foundation                          0x00000001c5501868  + 32
        2   Foundation                          0x00000001c5544370  + 540
        3   Foundation                          0x00000001c5543840  + 396
        4   Foundation                          0x00000001c554358c  + 272
        5   Foundation                          0x00000001c5542e10  + 264
        6   UIKitCore                           0x00000001f20d62e4  + 488
        7   UIKitCore                           0x00000001f20d67b0  + 36
        8   UIKitCore                           0x00000001f20d6eb0  + 84
        9   Foundation                          0x00000001c571d124  + 76
        10  Foundation                          0x00000001c54ff30c  + 108
        11  Foundation                          0x00000001c54fe304  + 328
        12  UIKitCore                           0x00000001f151dc0c  + 156
        13  UIKitCore                           0x00000001f151e0c0  + 152
        14  UIKitCore                           0x00000001f1514834  + 868
        15  UIKitCore                           0x00000001f1518760  + 104
        16  UIKitCore                           0x00000001f1543370  + 1772
        17  UIKitCore                           0x00000001f1546598  + 120
        18  UIKitCore                           0x00000001f14fc850  + 1452
        19  UIKitCore                           0x00000001f168f318  + 196
        20  UIKitCore                           0x00000001f168d330  + 144
        21  AppName                        0x0000000100b8ed00 $S12AppName18ViewControllerC11Func()ySS_S2StF + 4420
        22  AppName                        0x0000000100b8d9f4 $S12CcfU0_y10Foundation4DataVSg_So13NSURLResponseCSgs5Error_pSgtcfU_ + 2384
        23  App NAme                        0x0000000100a98f3c $S10Foundation4DataVSgSo13NSURLResponseCSgs5Error_pSgIegggg_So6NSDataCSgAGSo7NSErrorCSgIeyByyy_TR + 316
        24  CFNetwork                           0x00000001c513aa00  + 32
        25  CFNetwork                           0x00000001c514f1a0  + 176
        26  Foundation                          0x00000001c55ed8bc  + 16
        27  Foundation                          0x00000001c54f5ab8  + 72
        28  Foundation                          0x00000001c54f4f8c  + 740
        29  Foundation                          0x00000001c55ef790  + 272
        30  libdispatch.dylib                   0x000000010286f824 _dispatch_call_block_and_release + 24
        31  libdispatch.dylib                   0x0000000102870dc8 _dispatch_client_callout + 16
        32  libdispatch.dylib                   0x00000001028741c4 _dispatch_continuation_pop + 528
        33  libdispatch.dylib                   0x0000000102873604 _dispatch_async_redirect_invoke + 632
        34  libdispatch.dylib                   0x00000001028821dc _dispatch_root_queue_drain + 376
        35  libdispatch.dylib                   0x0000000102882bc8 _dispatch_worker_thread2 + 156
        36  libsystem_pthread.dylib             0x00000001c477917c _pthread_wqthread + 472
        37  libsystem_pthread.dylib             0x00000001c477bcec start_wqthread + 4
    )
    

提交回复
热议问题