Repository navigation
Conversation
Since 0.4.0 the Windows plugin's destructor called channel_->SetMethodCallHandler(nullptr). A plugin is destroyed from the registrar's destruction callback, which ~FlutterWindowsEngine runs after it has already detached the messenger from the engine (messenger_->SetEngine(nullptr); Stop();). FlutterDesktopMessengerSetCallback then dereferences the null engine, so every app that registers the plugin crashed with an access violation in flutter_windows.dll when its main window was closed, whether or not a webview had ever been opened. The handler is now left registered: the engine is shutting down and dispatches nothing more to it.
Leftover build output from a package that no longer exists on main; the only intended change is windows/web_view_window_plugin.cc.
Contributor
Author
|
A note on the red checks: they come from the Flutter stable rollover rather than from this change. CI installs the current stable, and
Both should affect any PR against Also: the first commit accidentally included generated files under |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, every app that registers the plugin crashes when its main window is closed, whether or not a webview was ever opened. It is an access violation (read at
0x1e8) insideflutter_windows.dll:Cause
The destructor added in #518 calls
channel_->SetMethodCallHandler(nullptr). The plugin is destroyed from the registrar's destruction callback, and the engine has already detached its messenger by then:FlutterDesktopMessengerSetCallbackthen callsGetEngine()->message_dispatcher()on the null engine. Its availability check is anFML_DCHECK, which is compiled out of shipped engines.Fix
Leave the handler registered. The engine is shutting down and dispatches nothing more to it, and the rest of the destructor (resetting
lifetime_, closing the windows) is unchanged.Verification
Flutter 3.47.9, Windows 11, x64 debug build of an app that depends on 0.4.2. Launch, wait for the first frame, close the main window, read the process exit code:
0xC000041D, 2 of 2 runsflutter_windows.dll0, 2 of 2 runsNo test is added: the crash happens while the process is exiting, after the integration test harness has gone.