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

[Bug] iOS platform crash if swipe from bottom up and root cause(maybe) #2471

Closed
shuoli84 opened this issue Sep 4, 2022 · 3 comments
Closed
Labels
B - bug Dang, that shouldn't have happened DS - ios F - duplicate This issue or pull request already exists

Comments

@shuoli84
Copy link
Contributor

shuoli84 commented Sep 4, 2022

Bug and trouble shooting

I've been debugging the crash bug for hours. It was reported by others and had a quick fix by setting ScreenEdge::ALL. Since the crash is reproducible, so I tried to tackle it down or at least find the root cause, I think I got something.
Currently, we create UIWindow first, then run UIApplicationMain, which is problematic, since UIApplicationMain actually setup some global state that UIKit requires, like following

Stack:
[UIGestureEnvironment init]
[UIApplication init]
UIApplicationInstantiateSingleton
_UIApplicationMainPreparations
UIApplicationMain

UIGestureEnvironment is also a singleton which is inited and stored inside UIApplication. Also, it is stored in each UIGestureRecognizer instance if it is already created. And UIGestureRecognizer is created when we create UIWindow, which means at that time, the global didn't created, so all the recognizer with _gestureEnvironment property as nil.

When ScreenEdge preference is 0, it triggers some logic of delay touch handling, and in that code path, it read the property as nil, which crashed when add into a nsarray.

How to fix:

UIWindow/UIView should be created by method on ApplicationDelegate, since UIApplicationMain will never return.

Other

Some evidence (crashed is the bevy_ios_example. good is a normal created ios app):

crashed:
(lldb) po ((_UISystemGestureGateGestureRecognizer*)0x15fe115f0) -> _gestureEnvironment
 nil

Good
(lldb) po ((_UISystemGestureGateGestureRecognizer *)0x101808750) -> _gestureEnvironment
<UIGestureEnvironment: 0x281ee4af0>

Crashed
Screen Shot 2022-09-04 at 22 25 53

Good call stack
Screen Shot 2022-09-04 at 22 24 46

@shuoli84
Copy link
Contributor Author

shuoli84 commented Sep 4, 2022

Good full stack, we can see the window is created inside UIApplicationMain.

Screen Shot 2022-09-04 at 22 37 27

Also link to original issue: #1705

@maroider maroider added B - bug Dang, that shouldn't have happened DS - ios F - duplicate This issue or pull request already exists labels Sep 4, 2022
@maroider
Copy link
Member

maroider commented Sep 4, 2022

Please post your findings under #1705, since it looks like all you've done is dig deeper into a potential root cause (which we really appreciate that you did). If you still feel this is a different enough issue, feel free to re-open this issue.

@maroider maroider closed this as completed Sep 4, 2022
@shuoli84
Copy link
Contributor Author

shuoli84 commented Sep 4, 2022

@maroider sure

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 DS - ios F - duplicate This issue or pull request already exists
Development

No branches or pull requests

2 participants