-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
hi, I found engine v1.12.13-hotfixes is not ok with the add to app. When I pushed multiple FlutterViewController and pop back, the app will crash due to accessing the nulled surface in Rasterizer::Setup. Here is my mini example to reproduce the problem: https://github.com/xujim/testaccessibility
The steps to reproduce the crash
Here is my add to app example to reproduce the crash bug:
https://github.com/xujim/testaccessibility
With this example installed, you just need to "Open Flutter Page", and again and again, then pop back the VC, finally, it crashed.
The Root Cause Analysis
It is caused by the sequence of Setup and Teardown of Rasterizer in the addToApps circumstance.
In the addToApps, we need to push and pop multiple VC, it will lead to setup and teardown of surface more than one time. And the setup and teardown tasks are queued by GPU thread.
However, note that the surface is held by on Engine, and the underlying memory is shared by the tasks(setup and teardown task) in the GPU thread queue. This will cause a situation, that a setup task need to access surface which has just been teardown in the last teardown task. Just as following diagram:

Change the Rasterizer::Setup function this way can avoid the crash, even though it might be not the best fix:

My Flutter Version
testaccessibility git:(master) ✗ flutter doctor -v
[✓] Flutter (Channel v1.12.13-hotfixes, v1.12.13+hotfix.8, on Mac OS X 10.14.6
18G95, locale zh-Hans-CN)
• Flutter version 1.12.13+hotfix.8 at
/Users/yujie/Desktop/FlutterWork/flutter_Github
• Framework revision 0b8abb4724 (4 周前), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0