-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Destroy the engine prior to application termination. #29295
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
I don't think this will fix crashing. It will just move the crash to some other spot. In fact, in the absence of graceful termination, I don't think there is a way to avoid crashes during termination. Apple's Technical Q&A QA1561 explicitly states "Do not call the exit function. Applications calling exit will appear to the user to have crashed, rather than performing a graceful termination and animating back to the Home screen." So, is the crash happening because someone called |
@chinmaygarde You're right, we may need to change all global mutex to heap allocated or handle the termination gracefully. From the backtrace of crash log, I think the crash happening because engine is not reacting to graceful termination, case like user swipe up from the bottom into app switcher, then kill the App directly, seems we didn't handle this case, I think we can destroy the engine when we check app will terminate, the code like below . |
Right, this seems to the most likely cause of the error. This would also explain why it's hard to observe or reproduce. Changing all global mutexes to be heap allocated and leaked will also not help because those mutexes guard process global information in the VM. So I think graceful termination is the only way to go. You patch to do so makes a lot of sense to me. Have you been able to reproduce the crash with your error reporting solution and swiping the app up to terminate it? If so, we can pretty confidently say we have the reproducible case. |
…d destructor fiasco" This reverts commit a2c913f.
@chinmaygarde Sorry, I didn't reproduce natively, but I think as long as we ensure terminate the engine before App called static global variables destructor, we can avoid the crash. |
|
macOS desktop also has a similar crash, which also happened in App closing, C++ destruction stage. |
|
Hey @zhongwuzw @chinmaygarde do you currently have a rough eta when this fix will land? |
Sorry, no eta currently, still under review. |
b1a8771 to
2962099
Compare
chinmaygarde
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I edited commit message to indicate what is actually going on in this patch. Othewise, LGTM.
39e9925 to
c1d16c9
Compare
|
This pull request is not suitable for automatic merging in its current state.
|
* 'Update Dart SDK to 1278bd5' * Update cirrus secret. * [iOS] Destroy the engine prior to application termination. (#29295) * Update licenses hash. * Update shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm Co-authored-by: Jenn Magder <[email protected]> Co-authored-by: Wu Zhong <[email protected]> Co-authored-by: Jenn Magder <[email protected]>
Try fixes flutter/flutter#90783.
Based on the full crash log, Flutter tries to use std::mutex when App is terminating. we can fix it by leaking global static mutex. React Native and ComponentKit also faced this issue, we can refer to them.
cc. @chinmaygarde
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.