Skip to content

About

Moved into Nucleus (webview module): https://github.com/NucleusFramework/Nucleus — the previous code is on the archive branch.

Resources

Stars

185 stars

Watchers

0 watching

Forks

Latest commit

 

History

122 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Compose Native WebView has moved into Nucleus

This project is not dead: its code now lives in the Nucleus repository, as the Kotlin Multiplatform webview module (desktop, Android, iOS, web), maintained and released there.

dependencies {
    implementation("dev.nucleusframework:nucleus.webview:3.0.0")
}

Coming from dev.nucleusframework:composewebview 1.0.x, the package and the API are the same: swap the dependency and move to Nucleus 3.0.

→ Migration guide from Compose Native WebView · WebView documentation

What's new

  • Several WebViews in one window on Windows.
  • Load errors reported in errorsForCurrentRequest on macOS and Linux, and WebView2 creation failures reported instead of crashing.
  • Keyboard: ⌘C / ⌘V / ⌘A and the other edit shortcuts work on macOS; undo / redo on Linux.
  • Linux fixes: no more black WebView on X11, no more crash on right click.
  • The JS bridge survives location.hash changes, and a bridge handler that throws no longer breaks it.
  • Text crosses JNI as UTF-16, so non-ASCII strings (emoji included) arrive intact.
  • Profiles: one persistent web context per data directory on Linux, a per-app default profile on Windows, dataDirectory honoured on macOS 14+.
  • Transparent pages: no forced white background on macOS and Linux.
  • Large HTML (over 2 MiB) loads on Windows.
  • Web target: the iframe is laid out by Compose (HtmlElementView) instead of floating over the canvas.
  • captureImageBitmapOrNull() captures the page as an ImageBitmap.

You don't need the whole framework

Nucleus is modular, and nucleus.webview is one artifact.

  • Android, iOS and the web: it is a library like any other. No Nucleus application, plugin or window.
  • The desktop is the exception: the WebView runs in Nucleus windows (nucleusApplication), as it already did in 1.0.x. The system's web engine (WebView2, WKWebView, WebKitGTK) is a native view embedded by the Nucleus window runtime, sized, clipped and focused with the Compose layout. The first versions of this library did it on AWT, the backend of Compose Desktop's windows: a heavyweight canvas in a SwingPanel, its bounds pushed by a timer, focus requested by hand, events pumped by another timer. Every one of those was a hack paid for in performance and too much for me to keep maintaining. Nucleus's window runtime is far more modern and built for exactly this kind of use.

Why it moved

A desktop WebView is a native view inside a window: it depends on the window runtime, on the native libraries for each OS, on packaging. Keeping it in its own repository meant following Nucleus from the outside, with its own build, its own CI and its own version. The 1.0.x line, for example, still pulled the 2.5 window artifacts after Nucleus 3.0 renamed them.

In the Nucleus repository the WebView is built, tested and released together with the rest of the framework:

  • One version for everything: the WebView you depend on is the one tested against the window runtime and the plugin of the same release.
  • A pipeline made for native libraries and every target: Nucleus's CI builds the native libraries for Windows, macOS and Linux (x64 and ARM64) on every change and publishes every Kotlin Multiplatform target, iOS included. A torture suite drives the real engines (WebView2, WKWebView, WebKitGTK on Wayland and X11).
  • Easier to maintain: one place to fix a bug, one changelog, one issue tracker.

Where things are now

  • Code: webview in the Nucleus repository.
  • Issues and pull requests: Nucleus issues. The issues open here were reviewed: those solved in Nucleus are closed with a pointer, those still relevant were opened again in Nucleus.
  • Old code: the last version of this repository (1.0.3 and its history) is kept, read-only, on the archive branch. Published versions stay on Maven Central (dev.nucleusframework:composewebview, and io.github.kdroidfilter:composewebview for the earlier Wry-based builds).

License

Apache-2.0, see LICENSE. Nucleus is MIT; its webview module keeps the Apache-2.0 notices of the code it derives from (see its THIRD_PARTY_NOTICES).

About

Moved into Nucleus (webview module): https://github.com/NucleusFramework/Nucleus — the previous code is on the archive branch.

Resources

Stars

185 stars

Watchers

0 watching

Forks

Releases

Contributors