Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multithreaded rendering only crashes on iOS 13

In my game engine, I have an option to enable the multithreaded rendering. In iOS 12 (and below) my app did not crash.

I have not changed anything in my code, but it crashes on iOS 13.

2019-10-02 11:36:07.931 SimpleGame[293:11150] ---> (Inner Exception #0) Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: threading violation: expected the main thread

Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    0   CoreFoundation                      0x00000001aace1c44 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 1256516
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    1   libobjc.A.dylib                     0x00000001aa9fc0c8 objc_exception_throw + 60
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    2   CoreFoundation                      0x00000001aabde75c 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 194396
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    3   Foundation                          0x00000001ab01f960 672CF0CB-4951-3B91-89DF-55E953AEA00F + 571744
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    4   FrontBoardServices                  0x00000001afe9791c 124B166D-3905-3F51-A46A-646AE3424213 + 366876
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    5   FrontBoardServices                  0x00000001afe4a288 124B166D-3905-3F51-A46A-646AE3424213 + 49800
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    6   UIKitCore                           0x00000001ae51a87c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1915004
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    7   UIKitCore                           0x00000001ae517554 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1901908
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    8   UIKitCore                           0x00000001ae5177b4 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1902516
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    9   UIKitCore                           0x00000001aeface14 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 13000212
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    10  UIKitCore                           0x00000001aedaf02c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10911788
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    11  UIKitCore                           0x00000001aedaff00 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10915584
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    12  
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    22  SimpleGame                   0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    23  SimpleGame                   0x00000001048b45e8 World_FlushRenderWorkQueue_private + 2808016
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    24  SimpleGame                   0x00000001048b54c0 World_FlushRenderWorkQueue_private + 2811816
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    25  SimpleGame                   0x00000001051d7198 World_FlushRenderWorkQueue_private + 12387456
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    26  SimpleGame                   0x000000010503c058 World_FlushRenderWorkQueue_private + 10703680
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    27  SimpleGame                   0x000000010503b774 World_FlushRenderWorkQueue_private + 10701404
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    28  SimpleGame                   0x00000001051d5400 World_FlushRenderWorkQueue_private + 12379880
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    29 SimpleGame                   0x000000010487d904 World_FlushRenderWorkQueue_private + 2583532
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    30  SimpleGame                   0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    31  SimpleGame                   0x000000010487c038 World_FlushRenderWorkQueue_private + 2577184
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    32  SimpleGame                   0x000000010487da00 World_FlushRenderWorkQueue_private + 2583784
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    33  SimpleGame                   0x00000001047081a8 World_FlushRenderWorkQueue_private + 1053840
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    34  SimpleGame                   0x0000000105bb1434 World_FlushRenderWorkQueue_private + 22718236
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    35  SimpleGame                   0x0000000105c18dd4 World_FlushRenderWorkQueue_private + 23142588
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    36  PSimpleGame                   0x0000000105c44080 World_FlushRenderWorkQueue_private + 23319400
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    37  libsystem_pthread.dylib             0x00000001aa9ecd5c _pthread_start + 128
Oct  2 09:57:48 GL04207-MT SimpleGame[923] <Notice>:    38  libsystem_pthread.dylib             0x00000001aa9f4c84 thread_start + 8

When I disable the multithreaded rendering option, it did not crash. There must be a change in the threading system in iOS 13, but could not find anything from their documetation.

like image 772
신한슬 Avatar asked Oct 02 '19 16:10

신한슬


1 Answers

As Gene said, the issue is that previous versions of iOS wouldn’t stop when you incorrectly interacted with the UI from a background thread. iOS 13 will.

To help identifying the issue, go to “Editor” » “Scheme” » “Edit Scheme...” and then check “Main Thread Checker”. If you tap on the right arrow next to this, it will even create a breakpoint for issues, where it will stop execution at the line at which you are trying to update the UI from a background thread:

enter image description here

like image 157
Rob Avatar answered Nov 15 '22 01:11

Rob