-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix WebView2 instances not recreating when environment options changed
WebView2 environment options are global to all instances in an environment, and an environment is associated with a disk folder where temporary data and user profile data is stored. Each environment also has a root browser process associated with it. If one attempts to alter an environment option and then create a new webview2 instance in an environment when there are existing instances, or the browser process is still running, then the creation will fail. Although most of the environment options are probably not things one might alter very often, they do include some weirdly misplaced properties like the scrollbar style, which seems like it ought to be per view. If this is changed in the Web Browser sample, the WebView2View attemps to recreate itself, but doesn't get very far. The reason is a race condition in the recreation process that the browser process doesn't shut down quickly enough, and as it is still running the attempt to create a new view with different options fails (silently). As the process shutdown is asynchronous, and there is an event fired, it seems like it might be feasible to wait for the event after destroying the existing view, and then create the new view on being notified. There are two problems with this: 1) the environment events were being torn down when the view was destroyed, so the event would never be received anyway, and 2) it is difficult to split the recreation logic so that the recreation can happen asynchronously on an event. A much more reliable approach that also allows views with different environment options to be open simultaneously, is to just ensure that the data folder paths are unique for a particular combination of options. If this is the case, then a new browser process is started when recreating with new environment options, and we don't need to wait for the old process to exit. The data folders names are made unique by appending a thumbprint generated from the environment settings. This is then hashed with MD5 to keep it reasonably short, and appended to the existing local app data path based on the application name.
- Loading branch information
Showing
14 changed files
with
246 additions
and
127 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.