·11 min read
Light Browser: a native C++ browser shell on WebView2 and WebKitGTK
Light Browser is a small browser for Windows and Linux that I wrote in C++. I do not ship a web engine: the Windows build is plain Win32 on top of Microsoft Edge WebView2, and the Linux build is GTK4 on WebKitGTK 6.0. I am the only developer, and the git history shows 103 commits and 49 published GitHub releases in about three weeks.
- Role
- Creator and sole developer
- Period
- Sep 2026 to Sep 2026
- Status
- Released v1.12.8 (Sep 30, 2026)
- Stack
- C++, Win32, WebView2, GTK4, WebKitGTK
- Live
- lightbrowser.net
The challenge
A browser is the hardest kind of app to ship small. Rendering, networking and security updates are enormous jobs, so I decided early not to do them. The cost is control: I can only do what the WebView2 API exposes, and every feature I wanted (blocking, runtime proxy switching, memory limits, encrypted sync) had to be built around that boundary.
The second difficulty is trust. A browser that blocks things can break sites in ways users blame on the browser, and a browser that reads other browsers' passwords looks exactly like malware to an antivirus. Most of the interesting problems in this project were one of those two.
My responsibility
I created and built Light Browser alone. The history shows me owning:
- The Win32 shell: window, tabs, toolbar, shortcuts, WebView2 wiring.
- The filter-list blocker, the request interception and the cosmetic rules.
- The memory manager: tab freezing, unloading, the RAM-limit cascade, deep sleep.
- The proxy relay, Tor routing, and the end-to-end encrypted sync client.
- The Linux port (GTK4 and WebKitGTK), including the
.deband tarball packaging. - The release pipeline: a tag-triggered GitHub Actions workflow, an Inno Setup installer, an auto-updater that reads GitHub Releases, optional code signing, and the winget manifest.
- Support work after release: crash pages with reasons, update-check fallbacks, and the stream of small fixes.
How I approached it
Layout of the code
The Windows side is split by responsibility: src/main.cpp (window, tabs, WebView2 wiring), src/adblock.* (blocklist and cosmetic rules), src/services.* (request interception and caching) and src/crypto.* (CNG and DPAPI wrappers). linux/main.cpp is the GTK shell and reuses src/adblock.cpp and the embedded internal pages through a small window.chrome.webview shim. That shim is the cheapest way I found to keep two shells from drifting apart.
| Area | Windows | Linux |
|---|---|---|
| Engine | WebView2 (Chromium) | WebKitGTK 6.0 |
| Shell | Win32 | GTK4 and libadwaita |
| Blocker | src/adblock.cpp directly | same code, converted to WebKit content-blocker JSON |
| Accounts, sync, passwords, import | yes | not yet |
The filter that took 215 sites offline
The blocker is intentionally not a full Adblock Plus engine. It accepts hosts files, my own |substring rules, and a strict subset of EasyList: ||host^ with an optional $third-party, path patterns, and ## cosmetic rules. Anything else is skipped. The comment on one line is the whole philosophy:
if (o != "third-party" && o != "3p") continue; // any other option changes meaningI learned that the hard way. On Sep 10, 2026 (c396f86) I fixed a bug where well-known sites such as chatgpt.com, bing.com and instagram.com would not load. The cause was in the list parser. Procedural cosmetic rules like site.com#?#selector matched none of my explicit branches, so they fell through to the hosts-file branch, where the text before the # was taken as a host to block. The commit message says it plainly: 215 sites were taken offline.
The fix did three things. It added an explicit skip for the #?#, #$#, #%# and #@?# syntaxes, with a comment recording what went wrong. It stopped treating a # glued to text as a trailing comment. And it fixed a second over-blocking cause in the same commit: $third-party rules had been treated as plain host rules, so they now live in their own set and only fire for cross-site requests.
// A '#' glued to the text is some other syntax, not a trailing comment.
if (hash == 0 || (line[hash - 1] != ' ' && line[hash - 1] != '\t')) continue;The principle that came out of it: if I cannot honor a rule exactly, I drop it. Lookup is a walk up the domain labels (a.b.c.com, b.c.com, c.com), each a hash lookup. Only sub-resources are blocked, never the main document, and the list is rebuilt off the UI thread and swapped with AdBlocker::Swap in O(1). On Linux the same sets become WebKit content-blocker JSON, capped near 150,000 rules.
The memory mode that crashed Figma
Most engineering after the basics went into RAM. On Sep 8 I added Chromium's low-end-device mode (c8cd03e) with a renderer limit of 4, then built the rest: freezing background tabs with TrySuspend, unloading idle ones, trimming the working set with EmptyWorkingSet, and a RAM-limit cascade that freezes, then unloads least-recently-used tabs, then squeezes the current page. Tabs with unsaved input or playing media are protected.
The next day the low-end mode came out (7f0ffa2, Sep 9). It halves V8 heap limits, and heavy apps like Figma died with out-of-memory exits. The same commit changed the renderer limit from 4 to 16, and left a comment in the code explaining why low-end mode is not used.
It also exposed a second issue in my own cascade. When only the current page was left, the cascade squeezed it on every sample, which can push a heavy app into an OOM exit itself. I added a throttle so the low target is applied once and the trim runs at most every 30 seconds:
if (now - lastActiveSqueeze_ < 30'000) return;
lastActiveSqueeze_ = now;The crash page now says why. The same commit reads the process-failed reason from WebView2 and shows "out of memory (exit code N)" with a hint to raise the RAM limit. I also replaced a hand-rolled private-memory count (a8cb57b, Sep 8) with PrivateWorkingSetSize, because the hand count undercounted and was denied on sandboxed renderers.
The import code that looked like an info-stealer
Reading other browsers' profiles means opening Login Data and calling CryptUnprotectData, which is what credential stealers do. The commit message for a42ec4c (Sep 9) says that code "was the main antivirus false-positive trigger". I moved it out of the browser into a separate lbimport.exe, downloaded on demand for the running version and verified by SHA-256. In that commit the tracked LightBrowser.exe build dropped from 2,345,984 to 1,323,008 bytes.
I handled the installer side of the same problem the day before: 971dd01 (Sep 8) made the installer per-user, so no red UAC "unknown publisher" prompt appears on install or auto-update. SmartScreen can still warn on first run because the binaries are not signed, and the README says so.
Proxy and Tor at runtime
WebView2 lets you pass --proxy-server at startup but never change it. I wanted routing to switch while running, so Chromium is pointed once at a local SOCKS5 relay that asks a resolver callback which upstream to use for each connection.
using Resolver = std::function<Upstream()>;The upstream can be direct, Tor's SOCKS port, a health-checked proxy pool, or a custom proxy. Turning the relay on or off still needs one restart, and free public proxies are marked untrusted in the UI.
Encrypted sync
From a passphrase and a server-provided salt, the client derives a master key with PBKDF2-SHA256 at 210,000 iterations, then splits it into encryption and MAC keys by hashing with different labels. Items are sealed with AES-256-GCM through Windows CNG, and item ids are HMACs, so the server sees only ciphertext under opaque keys.
Bytes master = lbcrypto::Pbkdf2Sha256(WToUtf8(passphrase), salt, 210000, 32);
encKey_ = lbcrypto::Sha256(Concat(master, "lb-enc").data(), master.size() + 6);
macKey_ = lbcrypto::Sha256(Concat(master, "lb-mac").data(), master.size() + 6);The cost is in the README: forget the passphrase and the data is gone. I chose that over a recovery path, because any recovery path means the server can read your data.
- 01
Passphrase and salt
the salt is provided by the server
- 02
PBKDF2-SHA256
210,000 iterations produce the master key
- 03
Split by label
hashing with lb-enc and lb-mac gives two keys
- 04
Seal with AES-256-GCM
Windows CNG encrypts each item
- 05
Opaque ids
item ids are HMACs, so the server sees only ciphertext
Windows exe per the README
bytes in my last local build
PBKDF2 iterations
approximate Linux rule cap
Project journey
Sep 2026
First commit
bb41ff1: browser with adblock, sync and browser import
Sep 2026
Auto-update and releases
50e6bb9: updater from GitHub Releases and a tag-driven release workflow
Sep 2026
Memory work
low-end mode, tab unloading, deep sleep, RAM-limit cascade
Sep 2026
Linux port
c17699b: GTK4 and WebKitGTK shell, then .deb and tarball in CI
Sep 2026
OOM and antivirus fixes
7f0ffa2 and a42ec4c, one day apart
Sep 2026
Over-blocking fix
c396f86: 215 sites back online
Sep 2026
Cookies and updater hardening
8b4cee4 and 1c8e584
Sep 2026
v1.12.8
latest release (Sep 30), with installer, portable exe, .deb and tarball
The dates matter here: the first commit is Sep 8, the Linux port is Sep 9, the over-blocking fix is Sep 10, and the last release in the history is Sep 30.
Beyond the launch
Releases kept coming after the first working version, and several of them were fixes for things only real use exposed:
8b4cee4(Sep 20): cookies were lost on exit. Chromium writes its cookie store during engine shutdown, and my host exited first. The same commit fixed the per-site ad switch not reaching the media ad script.1c8e584(Sep 30): the update check failed when GitHub's unauthenticated API limit (60 calls an hour per IP) was exhausted, which a shared address does quickly. I added a fallback that reads the Location header of/releases/latest, which is not rate limited, and builds the asset URLs from the tag.aa57056(Sep 30): background tabs stalled hidden iframes.- Release cadence: the public repo lists 49 releases from v1.0.0 to v1.12.8. The notes are short: a download line, Linux packages and
.sha256sidecars, with the Windows updater checking the checksum automatically. - Smaller fixes covered YouTube behavior, Google sign-in, imports from Opera GX, and autofill picking the wrong saved login.
What is still open: Linux has no accounts, sync, passwords or import, and the Windows binaries are unsigned, so SmartScreen warns on first run.
The outcome
Light Browser is released and public: v1.12.8 is the latest release on GitHub, the Windows build is a native C++ shell of roughly 2 MB, and a Linux build exists. The site is lightbrowser.net. The lessons I would pass on:
- A system engine is a good deal until you need a hook it does not have. Plan the workaround, like the relay, early.
- Parse less, but parse exactly. Skipping a rule is safe. Misreading one took 215 sites offline.
- Keep anything that looks like an info-stealer in its own binary, even if the intent is harmless.
Evidence
- Live site: lightbrowser.net
- Repo and releases: ddatunashvili/light_browser and its releases. The public repo holds only the README, the logo and the release binaries; the source tree is private, so I read my local copy.
- Commits relied on:
c396f86,7f0ffa2,a8cb57b,a42ec4c,971dd01,8b4cee4,1c8e584,aa57056,c8cd03e,c17699b - Files:
README.md,src/adblock.cpp,src/relay.cpp,src/crypto.cpp,src/syncclient.cpp,src/updater.cpp,linux/main.cpp,.github/workflows/release.yml - Microsoft Edge WebView2 documentation and WebKitGTK
Not verified: I did not benchmark memory use. The memory cascade and Linux feature status come from code and the README, the roughly 1.9 MB figure is the README's claim, and only the 2,137,088 byte size is something I measured on a local build. The 215 sites figure is from my commit message, not a re-count.
#cpp#webview2#webkitgtk#browser
Keep reading
Have a project in mind?