-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Problem
When the user hot reloads, the framework produces a frame immediately without waiting for the vsync using SchedulerBinding.scheduleWarmUpFrame. This warm up frame incorrectly calls FlutterView.render outside of the scope of PlatformDispatcher.onBeginFrame and PlatformDispatcher.onDrawFrame, which is not allowed as per FlutterView.render's docs.
This eventually calls into Animator::Render, which attempts to reuse the pending producer continuation. Normally the producer continuation is created by the vsync in Animator::BeginFrame. However, in the hot reload scenario we skipped waiting for a vsync, never called Animator::BeginFrame, and never created a producer continuation. As a result, the pending producer continuation is likely already committed and the scene will be dropped.
You can confirm this behavior by setting a breakpoint here and hot reloading: https://github.com/flutter/engine/blob/609e71543cb4bc996348ae316ff00a0ed252518c/shell/common/animator.cc#L157
Solution
First, we should test what breaks in google3 if the engine errors if FlutterView.render is called outside the scope of PlatformDispatcher.onBeginFrame and PlatformDispatcher.onDrawFrame.
Assuming the google3 test indicates this change is reasonable:
- Update hot reload's warm up frame to not call
FlutterView.render. Hot reload should likely setsendFramesToEnginetofalse. - Update the engine to error if
FlutterView.renderis called outside the scope ofPlatformDispatcher.onBeginFrameandPlatformDispatcher.onDrawFrame
Metadata
Metadata
Assignees
Labels
Type
Projects
Status