-
Notifications
You must be signed in to change notification settings - Fork 6k
[Windows] Fix EGL surface destruction race #51781
[Windows] Fix EGL surface destruction race #51781
Conversation
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.
RSLGTM, mostly to unblock the tree.
The code looks good (like, it's readable and the names and docs are good), I just can't tell you if it's "correct" for the domain, so defer to you on whether to land as-is or wait for more reviews.
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.
LGTM mod one question
fml::AutoResetWaitableEvent latch; | ||
engine.PostRasterThreadTask([&]() { | ||
surface.Destroy(); | ||
latch.Signal(); |
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.
What does this latch
accomplish? Does this prevent the engine from destructing before this task runs?
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.
Good question. This runs in the FlutterWindowsView
destructor, which owns the std::unique<egl::WindowSurface>
. The latch forced the destructor to wait until the surface was destroyed.
A cleaner version would be to just move the surface's ownership to the raster thread. I've updated it to that insead!
…146020) flutter/engine@8ec35b6...0a75166 2024-03-29 skia-flutter-autoroll@skia.org Roll Skia from a12e40efacea to df005a80da32 (1 revision) (flutter/engine#51777) 2024-03-29 737941+loic-sharma@users.noreply.github.com [Windows] Fix EGL surface destruction race (flutter/engine#51781) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jacksongardner@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This fixes the
WindowsTest.EngineCanTransitionToHeadless
flakiness reported by @matanlurey.EGL surfaces can only be used by a single thread at a time. Concurrent operations are unsafe.
Previously, the EGL surface was destroyed on the platform thread. This was safe as this always happened after the engine was shutdown and the raster thread was stopped. However, in a multi-view world a view can be destroyed while the engine is running. There may be pending raster tasks that operate on the render surface. Thus, the EGL surfaces should be destroyed on the raster thread when it is available.
This bug was introduced by #51681
Part of flutter/flutter#142845
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.