Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions shell/platform/windows/angle_surface_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ void AngleSurfaceManager::SetVSyncEnabled(bool enabled) {
LogEglError("Unable to update the swap interval");
return;
}

if (eglMakeCurrent(egl_display_, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT) != EGL_TRUE) {
LogEglError(
"Unable to release the context after updating the swap interval");
return;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what fixes the ANGLE roll. See: #45064

This is covered by existing tests and should be causing failures as it causes the context to be current on multiple threads.

}

bool AngleSurfaceManager::GetDevice(ID3D11Device** device) {
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/windows/flutter_windows_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class FlutterWindowsEngine {
bool MarkExternalTextureFrameAvailable(int64_t texture_id);

// Posts the given callback onto the raster thread.
bool PostRasterThreadTask(fml::closure callback);
virtual bool PostRasterThreadTask(fml::closure callback);

// Invoke on the embedder's vsync callback to schedule a frame.
void OnVsync(intptr_t baton);
Expand Down
7 changes: 6 additions & 1 deletion shell/platform/windows/flutter_windows_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,12 @@ void FlutterWindowsView::UpdateSemanticsEnabled(bool enabled) {

void FlutterWindowsView::OnDwmCompositionChanged() {
if (engine_->surface_manager()) {
engine_->surface_manager()->SetVSyncEnabled(binding_handler_->NeedsVSync());
// Update the surface with the new composition state.
// Switch to the raster thread as this requires making the context current.
auto needs_vsync = binding_handler_->NeedsVSync();
engine_->PostRasterThreadTask([this, needs_vsync]() {
engine_->surface_manager()->SetVSyncEnabled(needs_vsync);
});
}
}

Expand Down
8 changes: 8 additions & 0 deletions shell/platform/windows/flutter_windows_view_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class MockFlutterWindowsEngine : public FlutterWindowsEngine {
MockFlutterWindowsEngine() : FlutterWindowsEngine(GetTestProject()) {}

MOCK_METHOD0(Stop, bool());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See: #45307

MOCK_METHOD1(PostRasterThreadTask, bool(fml::closure));

private:
FML_DISALLOW_COPY_AND_ASSIGN(MockFlutterWindowsEngine);
Expand Down Expand Up @@ -1280,6 +1281,13 @@ TEST(FlutterWindowsViewTest, UpdatesVSyncOnDwmUpdates) {
std::unique_ptr<MockAngleSurfaceManager> surface_manager =
std::make_unique<MockAngleSurfaceManager>();

EXPECT_CALL(*engine.get(), PostRasterThreadTask)
.Times(2)
.WillRepeatedly([](fml::closure callback) {
callback();
return true;
});

EXPECT_CALL(*window_binding_handler.get(), NeedsVSync)
.WillOnce(Return(true))
.WillOnce(Return(false));
Expand Down