Skip to content

platform views on by default introduced a race condition #69449

@gaaclarke

Description

@gaaclarke

flutter/engine#20671 seems to have introduced a race condition.

The crash can happen here:

#6	0x00000001044659d0 in flutter::FlutterPlatformViewsController::SubmitFrame(GrDirectContext*, std::__1::shared_ptr<flutter::IOSContext>, std::__1::unique_ptr<flutter::SurfaceFrame, std::__1::default_delete<flutter::SurfaceFrame> >) at /Users/aaclarke/dev/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm:473
#7	0x00000001044eb214 in flutter::IOSExternalViewEmbedder::SubmitFrame(GrDirectContext*, std::__1::unique_ptr<flutter::SurfaceFrame, std::__1::default_delete<flutter::SurfaceFrame> >) at /Users/aaclarke/dev/engine/src/flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm:79
#8	0x00000001055f7700 in flutter::Rasterizer::DrawToSurface(flutter::LayerTree&) at /Users/aaclarke/dev/engine/src/flutter/shell/common/rasterizer.cc:474
#9	0x00000001055f8ce8 in flutter::Rasterizer::DoDraw(std::__1::unique_ptr<flutter::LayerTree, std::__1::default_delete<flutter::LayerTree> >) at /Users/aaclarke/dev/engine/src/flutter/shell/common/rasterizer.cc:339
#10	0x00000001056057c4 in flutter::Rasterizer::Draw(fml::RefPtr<flutter::Pipeline<flutter::LayerTree> >, std::__1::function<bool (flutter::LayerTree&)>)::$_1::operator()(std::__1::unique_ptr<flutter::LayerTree, std::__1::default_delete<flutter::LayerTree> >) const at /Users/aaclarke/dev/engine/src/flutter/shell/common/rasterizer.cc:172
2020-10-30 17:45:01.323016-0700 DoubleEngine[1495:367001] [VERBOSE-3:FlutterPlatformViews.mm(473)] Check failed: flutter_view_.

The FlutterPlatformViewsController::SetFlutterView isn't guaranteed to execute before FlutterPlatformViewsController::SubmitFrame (see #69449 (comment)).

Further investigation also shows that FlutterPlatformViewsController had race conditions. Data is getting set on the platform thread and read on the raster thread without any synchronization (for example flutter_view_).

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressionc: crashStack traces logged to the consolec: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions