MicrosoftEdge / MicrosoftEdge/WebView2Feedback
ExecuteScript delayed until NavigationCompleted event for a cancelled navigation
@champnic is already working on this.
Since Oct 26, 2021.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
We have an app that interacts with the webapps it displays.
This application uses, for historical reasons and because the different webapps require different browser versions, IE 11 and CEF. Now we also want to add the possibility of using WebView2.
For legacy reasons, the communication between the application and the webapps is implemented like this:
• A webapp sends a command to the application with a url navigation. When the application detects that the pattern of the url corresponds to a command, it cancels the navigation and executes the corresponding command.
• The application sends commands to the webapp using javascript.
In response to a command from a webapp (url navigation cancelled) the application can send several commands (javascript) to the webapp.
The issue with WebView2 is that scripts (ExecuteScript) are not executed on the webapp until the NavigationCompleted event and this introduces a significant latency which degrades the user experience. We don't have this issue with CEF where navigation is caught in OnBeforeBrowse.
The documentation says "If the method is run after the NavigationStarting event during a navigation, the script runs in the new document when loading it, around the time ContentLoading is run"
- Is there is a way for the javascript to run immediately when the navigation is cancelled (in the NavigationStarting handler)
- Why the "NavigationCompleted" event could not be synchronous with the "NavigationStarting" event in case the navigation is cancelled?
- Is there any other way to avoid this delay between calling ExeuteScript and the actual execution of the script in case we have a cancelled NavigationStarting ?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.