Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Crashed by *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil #1613

Closed
inoutch opened this issue Jun 28, 2020 · 9 comments
Closed
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - ios

Comments

@inoutch
Copy link

inoutch commented Jun 28, 2020

If I tap on the moment it starts up on iOS, the following error occurs and the app finished.

2020-06-28 20:11:01.732058+0900 <project-name>[58982:6919187] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x1c4642a48 0x1c4369fa4 0x1c4698360 0x1c46979f4 0x1c451a120 0x1c82ba31c 0x1c82ba4f8 0x1c82ba71c 0x1c82bb460 0x1c82af4c0 0x1c82aec38 0x1c82ae9fc 0x1c8704374 0x1c86e0a9c 0x1c8758c20 0x1c875b17c 0x1c8753ff0 0x1c45c0a00 0x1c45c0958 0x1c45c00f0 0x1c45bb23c 0x1c45baadc 0x1ce55b328 0x1c86c863c 0x104d324f4 0x104d5f45c 0x104d0f71c 0x104be78e4 0x104be7930 0x104be7a94 0x104be7b7c 0x104be79f0 0x104be7870 0x104be7c68 0x104be790c 0x104be7848 0x1c4444360)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Xcode wrote the following stack trace for me.
スクリーンショット 2020-06-28 20 34 18

スクリーンショット 2020-06-28 20 34 31

UIKitCore`UIApplicationMain:
    0x1c86c7eac <+0>:    sub    sp, sp, #0xa0             ; =0xa0 
    0x1c86c7eb0 <+4>:    stp    x28, x27, [sp, #0x40]
    0x1c86c7eb4 <+8>:    stp    x26, x25, [sp, #0x50]
    0x1c86c7eb8 <+12>:   stp    x24, x23, [sp, #0x60]
    0x1c86c7ebc <+16>:   stp    x22, x21, [sp, #0x70]
    0x1c86c7ec0 <+20>:   stp    x20, x19, [sp, #0x80]
    0x1c86c7ec4 <+24>:   stp    x29, x30, [sp, #0x90]
    〜 omitted 〜
    0x1c86c8610 <+1892>: bl     0x1c441e9d8               ; kdebug_trace
    0x1c86c8614 <+1896>: mov    x0, x23
    0x1c86c8618 <+1900>: bl     0x1c4384130               ; objc_release
    0x1c86c861c <+1904>: ldr    x0, [sp, #0x28]
    0x1c86c8620 <+1908>: bl     0x1c4384130               ; objc_release
    0x1c86c8624 <+1912>: ldr    x0, [sp, #0x30]
    0x1c86c8628 <+1916>: bl     0x1c8c03944               ; symbol stub for: -[UIDocumentSharingController _setMailSubject:]
    0x1c86c862c <+1920>: ldr    x0, [x20, #0xd08]
    0x1c86c8630 <+1924>: adrp   x8, 213832
    0x1c86c8634 <+1928>: add    x1, x8, #0x378            ; =0x378 
    0x1c86c8638 <+1932>: bl     0x1c4366080               ; objc_msgSend
->  0x1c86c863c <+1936>: ldr    x0, [sp, #0x38]
    0x1c86c8640 <+1940>: bl     0x1c4384130               ; objc_release
    0x1c86c8644 <+1944>: mov    x0, x22
    0x1c86c8648 <+1948>: bl     0x1c4384130               ; objc_release

My codes
https://github.com/inoutch/tearchan/blob/03edc923569011a0c8e10ac97f1e0e77e5a4574d/src/core/engine.rs#L67-L93

Inexplicably, if I wait for a few seconds after app starting and tap later, it doesn't finish, and it also get the touch event successfully. Also, I use gfx-rs in addition to winit-rs and do present surface or not, an error may or may not occur (This is not related to gfx-rs, and to timing issue?)

@inoutch
Copy link
Author

inoutch commented Jun 30, 2020

This problem was reproduced by the example of gfx-rs with some modifications.
https://github.com/inoutch/crossplatform_gfx_hal_example/tree/bug-report

[Some modifications]
inoutch/crossplatform_gfx_hal_example@27746b0

Device: iPhone X
iOS: 13.3.1
スクリーンショット 2020-06-30 10 21 01

I've reported the problem to the winit-rs repository due to the crash caused by the touch event, but if it's a problem on the gfx-rs side, I'll report it to it.
Also, if there is any mistake, please point out to me.

@francesca64 francesca64 added DS - ios C - needs investigation Issue must be confirmed and researched B - bug Dang, that shouldn't have happened labels Jun 30, 2020
@francesca64
Copy link
Member

Thanks for reporting this! It certainly sounds like an issue here in winit.

It looks like you're using winit 0.21: https://github.com/inoutch/crossplatform_gfx_hal_example/blob/27746b0124ebc9e062afc9397d6e3f43d6ab7a01/rust/game_lib/Cargo.toml#L20

Can you still reproduce this using winit 0.22.2?

@inoutch
Copy link
Author

inoutch commented Jul 1, 2020

Thank you for your quick reply.
Update winit-rs version to 0.22.2, and build and run after deleting the target folder, and it still has the same problem.
inoutch/crossplatform_gfx_hal_example@4e4cf5d#diff-caf063a844fa39631e1a2a0a7b865c12

@simlay
Copy link
Contributor

simlay commented Jul 1, 2020

Hmm. So, it could be entirely unrelated but I've had a similar bug with some of my UIKit WIP for iced. When I start the app and use the UIView to add some subviews, if I tap on the subview before I tap on anything other than a subview, it crashes. So, the work around I've been doing to test that the views are setup correctly is to tap on anything other than say a text box and then tap on the text box... This results in a few touch events and then I can tap on my text input box and do things.

If I tap directly on the input box at first without touching the background view, it crashes with the following stack trace:

2020-06-30 23:06:50.329 ios-example[68349:4586192] *** Assertion failure in -[UIGestureGraphEdge initWithLabel:sourceNode:targetNode:directed:], /Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3920.31.100/Source/GestureGraph/UIGestureGraphEdge.m:24
2020-06-30 23:06:50.366 ios-example[68349:4586192] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: sourceNode'
*** First throw call stack:
(
        0   CoreFoundation                      0x00007fff23e3cf0e __exceptionPreprocess + 350
        1   libobjc.A.dylib                     0x00007fff50ba89b2 objc_exception_throw + 48
        2   CoreFoundation                      0x00007fff23e3cc88 +[NSException raise:format:arguments:] + 88
        3   Foundation                          0x00007fff258b8bd2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
        4   UIKitCore                           0x00007fff48805c0f -[UIGestureGraphEdge initWithLabel:sourceNode:targetNode:directed:] + 386
        5   UIKitCore                           0x00007fff48802662 -[UIGestureGraph addUniqueEdgeWithLabel:sourceNode:targetNode:directed:properties:] + 658
        6   UIKitCore                           0x00007fff488112d2 -[UIGestureEnvironment _addDynamicRequirementForGestureRecognizer:requiringGestureRecognizerToFail:] + 149
        7   UIKitCore                           0x00007fff488133f9 _UIGestureEnvironmentUpdate + 967
        8   UIKitCore                           0x00007fff48812ff4 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 467
        9   UIKitCore                           0x00007fff48812d7c -[UIGestureEnvironment _updateForEvent:window:] + 225
        10  UIKitCore                           0x00007fff48cca2fb -[UIWindow sendEvent:] + 4479
        11  UIKitCore                           0x00007fff48ca4755 -[UIApplication sendEvent:] + 356
        12  UIKitCore                           0x00007fff48d2f552 __dispatchPreprocessedEventFromEventQueue + 7628
        13  UIKitCore                           0x00007fff48d32716 __handleEventQueueInternal + 6584
        14  UIKitCore                           0x00007fff48d28fb9 __handleHIDEventFetcherDrain + 88
        15  CoreFoundation                      0x00007fff23da0d31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
        16  CoreFoundation                      0x00007fff23da0c5c __CFRunLoopDoSource0 + 76
        17  CoreFoundation                      0x00007fff23da0434 __CFRunLoopDoSources0 + 180
        18  CoreFoundation                      0x00007fff23d9b02e __CFRunLoopRun + 974
        19  CoreFoundation                      0x00007fff23d9a944 CFRunLoopRunSpecific + 404
        20  GraphicsServices                    0x00007fff38ba6c1a GSEventRunModal + 139
        21  UIKitCore                           0x00007fff48c8b9ec UIApplicationMain + 1605
        22  ios-example                         0x0000000105bbf616 _ZN5winit13platform_impl8platform10event_loop18EventLoop$LT$T$GT$3run17h8a9c32cbfbf0edd9E + 2182
        23  ios-example                         0x0000000105bd1b8b _ZN5winit10event_loop18EventLoop$LT$T$GT$3run17h0cc7d43eada55386E + 75
        24  ios-example                         0x0000000105bd2a78 _ZN8iced_ios11application11Application3run17h1329392dead6371aE + 1256
        25  ios-example                         0x0000000105bb7651 _ZN4iced11application11Application3run17hb9e2e3ffb1788768E + 17
        26  ios-example                         0x0000000105bb77f1 _ZN4iced7sandbox7Sandbox3run17hc6bdcc433081aff2E + 49
        27  ios-example                         0x0000000105bc450a _ZN11ios_example4main17h8c33c294d5021811E + 106
        28  ios-example                         0x0000000105bd18de _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hb99016a139a28815E + 14
        29  ios-example                         0x0000000105ee4428 _ZN3std9panicking3try7do_call17h53b7a2c20bfe2b9aE + 24
        30  ios-example                         0x0000000105ee61cb __rust_maybe_catch_panic + 27
        31  ios-example                         0x0000000105ee4b85 _ZN3std2rt19lang_start_internal17hc274c1ce0c33d6d7E + 149
        32  ios-example                         0x0000000105bd18c1 _ZN3std2rt10lang_start17h1b4b9e56d8e43005E + 65
        33  ios-example                         0x0000000105bc4a22 main + 34
        34  libdyld.dylib                       0x00007fff51a231fd start + 1
        35  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@francesca64
Copy link
Member

@inoutch thanks for checking. I've succeeded in using your example to reproduce this on my iPhone XR... it's very interesting that this only happens within that area. I'm not able to reproduce this if I comment out all of your rendering code. I'm also not able to reproduce this in my own application, which also uses gfx-hal. I tried adding the fancy UIView subclassing logic from my application to your example to see if it'd make a difference, but no dice. I'm going to continue to bisect this.

@simlay ah, iOS support in iced would be quite cool! The Original Exception Backtrace I get when reproducing this looks similar to the one you posted, so it seems likely that this is related. Do you have this up in a repo somewhere?

Screen Shot 2020-07-01 at 14 37 32

@aentity
Copy link

aentity commented May 11, 2021

i confirm, I have also received this crash when i tap near when app begins, in top left corner, same exception. using winit 0.24, iced 0.4, and wgpu 0.7

@tachyon-ops
Copy link
Contributor

I confirm IOS ScreenEdge Corrected Default #1843 solves my issue with this error (extensively tested and now using my winit fork with that PR applied).

@madsmtm
Copy link
Member

madsmtm commented Sep 8, 2024

I suspect this is fixed by #3447 and #3826 (we first deprecated, and now disallow creating windows before the application has been initialized).

@madsmtm
Copy link
Member

madsmtm commented Nov 21, 2024

I will assume that this has been fixed as per the above comment, feel free to re-open if that is not the case.

@madsmtm madsmtm closed this as completed Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - ios
Development

Successfully merging a pull request may close this issue.

6 participants