Skip to content

feat: Replace CefSharp with Microsoft Edge WebView2 - #276

Open
CyberCriminal0 wants to merge 1 commit into
GermanCoding:mainfrom
CyberCriminal0:feat/webview2
Open

feat: Replace CefSharp with Microsoft Edge WebView2#276
CyberCriminal0 wants to merge 1 commit into
GermanCoding:mainfrom
CyberCriminal0:feat/webview2

Conversation

@CyberCriminal0

@CyberCriminal0 CyberCriminal0 commented Aug 30, 2026

Copy link
Copy Markdown

Closes #179

This work originated from some stuttering issues I had running this software on a high DPI monitor, the CEF webui appeared to render the Syncthing UI at a much lower framerate than my own monitor and with some infrequent graphical artifacts. Testing with Windows 11's native WebView2 resolves issues like this and likely would provide the same functionality without the external CEF dependency. WebView2 is native to Windows 11 and ships to Windows 10 via Edge.

The Syncthing UI was hosted in CefSharp.Wpf's ChromiumWebBrowser, which uses CEF's windowless (off-screen) rendering mode. Every frame was rasterised on the CPU, copied in full into a MemoryMappedFile on the CEF UI thread, marshalled to the WPF dispatcher, copied a second time into a WriteableBitmap, and only then uploaded to the GPU. CEF also caps windowless rendering at 30fps by default, and forces GPU compositing off, so the page was rasterised entirely by Skia on the CPU.

At 1920x1080 that is 8.3MB per frame for the first copy alone. On a high-DPI display it is considerably worse, and the second copy happens on the UI thread, so the whole application stutters along with it.

WebView2 hosts a real child window and composites on the GPU, so none of those copies happen at all.

Notable details:

  • The zoom level is still stored in configuration on CEF's logarithmic scale, so existing config files keep working. It is converted to WebView2's linear ZoomFactor on use.
  • The JavaScript bridge for "open folder" and "browse for folder" now uses postMessage/WebMessageReceived rather than a registered host object.
  • WebView2 hosts a native child window, which paints over WPF content in the same grid cell, so the browser is collapsed while the "Syncthing starting/stopped" messages are showing.
  • The Intel Xe graphics warning is removed: it existed because CEF's off-screen rendering misbehaved on those drivers. The "disable hardware rendering" setting remains and still applies to SyncTrayzor's own WPF interface.
  • The CEF cache lockfile check is removed. WebView2 allows several processes to share a user data folder, so a second SyncTrayzor instance is no longer a problem.
  • Cache-disabling and the stripping of If-None-Match/If-Modified-Since headers are dropped. These worked around CEF-specific behaviour; Syncthing serves its assets with correct cache validators.

The browser's data now lives in data\webview2 (portable) or %LOCALAPPDATA%\SyncTrayzor\webview2 (installed).

SyncTrayzor now requires the Microsoft Edge WebView2 Runtime, which ships with Windows 11 and reaches Windows 10 via Microsoft Edge. If it is missing, SyncTrayzor offers a link to the download page and carries on running Syncthing normally.

Testing:

task test — 58/58 passing.
Builds clean for win-x64; no new warnings.

The Syncthing UI was hosted in CefSharp.Wpf's ChromiumWebBrowser, which
uses CEF's windowless (off-screen) rendering mode. Every frame was
rasterised on the CPU, copied in full into a MemoryMappedFile on the CEF
UI thread, marshalled to the WPF dispatcher, copied a second time into a
WriteableBitmap, and only then uploaded to the GPU. CEF also caps
windowless rendering at 30fps by default, and forces GPU compositing off,
so the page was rasterised entirely by Skia on the CPU.

At 1920x1080 that is 8.3MB per frame for the first copy alone. On a
high-DPI display it is considerably worse, and the second copy happens on
the UI thread, so the whole application stutters along with it.

WebView2 hosts a real child window and composites on the GPU, so none of
those copies happen at all.

Notable details:

- The zoom level is still stored in configuration on CEF's logarithmic
  scale, so existing config files keep working. It is converted to
  WebView2's linear ZoomFactor on use.
- The JavaScript bridge for "open folder" and "browse for folder" now
  uses postMessage/WebMessageReceived rather than a registered host
  object.
- WebView2 hosts a native child window, which paints over WPF content in
  the same grid cell, so the browser is collapsed while the "Syncthing
  starting/stopped" messages are showing.
- The Intel Xe graphics warning is removed: it existed because CEF's
  off-screen rendering misbehaved on those drivers. The "disable hardware
  rendering" setting remains and still applies to SyncTrayzor's own WPF
  interface.
- The CEF cache lockfile check is removed. WebView2 allows several
  processes to share a user data folder, so a second SyncTrayzor instance
  is no longer a problem.
- Cache-disabling and the stripping of If-None-Match/If-Modified-Since
  headers are dropped. These worked around CEF-specific behaviour;
  Syncthing serves its assets with correct cache validators.

The browser's data now lives in data\webview2 (portable) or
%LOCALAPPDATA%\SyncTrayzor\webview2 (installed).

SyncTrayzor now requires the Microsoft Edge WebView2 Runtime, which ships
with Windows 11 and reaches Windows 10 via Microsoft Edge. If it is
missing, SyncTrayzor offers a link to the download page and carries on
running Syncthing normally.
@GermanCoding

Copy link
Copy Markdown
Owner

Hi, thanks for the contribution. I don't have time to review this today, so it'll likely have to wait another week, but I'll take a look when I can!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider replacing CEF with WebView2

2 participants