MicrosoftEdge / MicrosoftEdge/WebView2Feedback

img tag source loading - stuck in pending network status

Open
#1,175 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

For reference - for a local folder index.html source in the webview2 control.
The img sources were coded something like:

<img src="../user/items/image1.png"/>

The network requests for img source would sit in 'Pending' for a long time, and then all calls for resources after about 10-20 seconds would load fine.

The resolution was to immediately map a virtual host name to the local folder after EnsureCoreWebView2Async and use proper address source.

await AppWebView.EnsureCoreWebView2Async(null);
AppWebView.CoreWebView2.SetVirtualHostNameToFolderMapping("SLG.user", slg.appPath + "user/items/", CoreWebView2HostResourceAccessKind.DenyCors);
<img src="https://SLG.user/image1.png"/>

The pending network status no longer occurs and images load immediately. I assume some initial handshake/connection for the control to the actual local folder path was taking some time. Whether this is a bug or not, I can't be sure - it is likely better practice to set up the virtual host name anyway.

AB#32524620

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with a local-folder index.html in a WebView2 control and reproduce the relative image source behavior described in the issue. Compare loading with the virtual host mapping and HTTPS image source shown in the report; done means determining whether the pending requests indicate a WebView2 bug or documenting the required setup and expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, html
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.