Skip to content
  1. Docs
  2. Apps
  3. Developers

Browser internals

How Browser embeds WPE WebKit, how its windows and engine work are organized, how content blocking is built, and how its dependencies are pinned.

Browser is a native enzUI app that embeds WPE WebKit. This page describes how the engine is integrated, how content blocking works and how the build pins its dependencies. For using the browser, see Browser.

Build and run

Prepare the pinned native WebKit SDK and runtime first using the Browser development guide. With that SDK environment active:

sh
./tools/build
./tools/browser
./tools/browser https://example.com
./tools/browser --private-window

tools/build builds the enzim-browser binary offline and locked, with one compiler job, inside a systemd scope capped at 3 GiB with no swap. tools/browser launches it against the pinned WPE runtime. WebKit sandboxing and the native destination guard stay enabled. ./tools/test runs the behaviour checks under the same ceiling.

Pinned dependencies

Cargo resolves the public enzUI, iced and winit revisions recorded in DEPENDENCIES.json and Cargo.lock. Browser 0.1.3 also pins the WebKit Rust adapter in a sibling checkout and uses the enzim WebKit 0.1.1 runtime and SDK for Arch Linux x86_64. Keep the unpacked native archives outside the Browser checkout.

Process and thread model

  • All browser windows run in one process; src/windows.rs keeps one application state per window. Normal windows share native storage and preferences; each private window gets separate ephemeral profiles.
  • WebKit calls go through a single dedicated worker thread, or the main thread where the runtime requires it (src/webview_native.rs).
  • PDF documents are parsed by Poppler's command-line tools inside a bwrap sandbox (src/pdf.rs), with renders off the UI thread and superseded requests discarded.

Source layout

ModuleOwns
src/browser.rs and src/browser_*.rsbrowser surfaces: tabs, containers, developer tools, inspector, network view, shields, privacy, cookies, history, downloads, zoom, find
src/webview.rspage state, input routing and frame publication
src/webview_native.rs, src/native_jobs.rsWebKit workers and native actions
src/profiles.rscontainers and their storage profiles
src/filters.rscontent-blocking rule conversion and caching
src/search.rssearch engines and templates
src/pdf.rsthe sandboxed PDF reader
src/surface_input.rspointer and wheel input, including zoom

Content blocking

Ad and tracker blocking combines three mechanisms:

  1. Network filters. src/filters.rs uses Brave's adblock crate to convert the bundled EasyList and EasyPrivacy lists, plus a video-ad list, into WebKit content-blocking rule sets. Converted rule sets are cached per protection mode. Unless Strict mode is on, block rules apply to third-party requests only.
  2. Cosmetic clean-up. A cosmetic engine, which also uses the uBlock list, hides ad containers.
  3. Document-start scriptlets. Scriptlets run before page scripts; for example, YouTube player scriptlets remove ad data while keeping the video response.

Per-site exceptions are added per exact origin (including the port), separately for ads and trackers. Some procedural and response-replacement rules are not supported. Cookie and tracking-prevention policies are global because they apply to the native storage session.

Site icons

WebKit discovers and decodes favicons natively, including cross-origin icons and pages with JavaScript disabled. Native content filters and destination restrictions apply before the request. The browser validates document ownership before adopting a bounded PNG result, then caches icons by HTTP(S) origin under $XDG_CACHE_HOME/enzim-browser/favicons. Private windows keep new icons in memory only.

Downloads

Downloads are native. Pause and resume are offered while the browser stays open when the server provides suitable byte ranges and a validator; a resumed response is checked before its retained prefix is joined to the new body. A server that returns a complete replacement restarts the file, and invalid ranges fail visibly. Blob downloads generated by pages cannot be resumed. python3 tools/check_downloads.py exercises these cases against isolated storage.

Diagnostics

A benchmark feature build (./tools/build --features benchmark) adds probes for scroll latency, audio volume behaviour, native asset and icon handling, and privacy filter enforcement. They run against local fixtures with an isolated QA profile and leave normal profiles alone.