Nimbin[12]?Web & Tools / Browser

Browser git · main

Minimal browser in C (mini and big variant)

browser c · first commit 2026-08-25 · last commit 2026-11-12 (12 days ago) · synced 1 hour ago · upstream: github.com/nimbin2/Browser

C 95.6% Markdown 4.2%
git clone https://git.christianimmanuel.de/web-tools/Browser.gitwget https://git.christianimmanuel.de/web-tools/Browser/archive/Browser.tar.gz
80991a6Enable storage api and filesystemChristian Immanuel · 12 days ago
-.gitignore25 B
-bigbrowser.c47.9 KB
-browser-big.c132.2 KB
-browser-mini.c560 B
-browser_core.c286.2 KB
-browser_core.h7.7 KB
-gst-glupload-null-meta.patch488 B
-HANDOVER.md8.2 KB
-Makefile1.3 KB
-minibrowser.c555 B
-README.md12.5 KB
-webkit-caps-normalize.patch827 B
-webkit-videorate-skip-to-first.patch807 B

README.md

browser-mini / browser-big

Two WebKitGTK 6.0 (GTK4) browsers sharing one core.

100% Vibecode but tested. Builds warning-free with -Wall -Wextra. Used for real video calls on WebKitGTK 2.54.0 with GStreamer 1.28.7.

  • browser-mini: a plain, fast page viewer.
  • browser-big: the same, plus camera, microphone and WebRTC repairs and
  • diagnostics.

Files

FileWhat it is
browser_core.c / .hWindow, keys, history, downloads, profiles, config
browser-mini.cFills in the hooks and calls browser_main()
browser-big.cCamera, GStreamer and WebRTC repairs, diagnostics
patches/Three upstream fixes for WebKitGTK and GStreamer (see Patches)
HANDOVER.mdBackground: each upstream bug and workaround, with evidence

Build

Debian or any Linux distro:

apt install build-essential pkg-config libgtk-4-dev libwebkitgtk-6.0-dev \
            libsoup-3.0-dev libgstreamer1.0-dev
make                # build both
make install        # into /usr/bin (PREFIX=... to change)
make uninstall
make clean
make version        # 4.47.0 (build …), md5 of the sources

Usage

browser-mini [URL] [options]
browser-big  [URL|PATH|diag] [options]

No address opens the start page. No scheme means https; a path opens as a file. -h lists every option and key.

Keys

KeyAction
Ctrl+O, Ctrl+LAddress (history below it)
Ctrl+HHistory
Ctrl+J / Ctrl+Shift+JBack / forward
Ctrl+FFind
Ctrl+SDownload directory for page, site or everything
Ctrl+KSearch keywords
Ctrl+DRecent downloads
Ctrl+P / Ctrl+YShow / copy the URL
Ctrl+G / Ctrl+Shift+GTop / bottom
Ctrl+R, F5Reload
Ctrl+plus/minus/0Zoom
F1Key list
F2Media mode (Ctrl+click sends videos to player, images to image_viewer)
F6Redraw without reloading
F12Developer tools

--mod alt|super|meta moves the modifier off Ctrl. browser-big adds Ctrl+Shift+M (diagnostics page), Ctrl+Shift+T (web process threads), Ctrl+Shift+V (video element state), Ctrl+Shift+C / X (warm / release the camera).

Features

  • History survives restarts; back and forward continue into it.
  • --private keeps nothing.

  • Downloads: Ctrl+S sets a directory per page, site or everything;
  • the narrowest rule wins.

  • Search keywords: g (default), d, w, s. w tree searches
  • Wikipedia. Add one with Ctrl+K: k https://example.org/?q={}.

  • Lock: --lock-page or --lock-site refuses other addresses.
  • Popups: --allow-popups lets pages open windows without a click
  • (Zoom needs it).

  • Errors show top right in red for 10 s, and on stderr.

Paths

browser-mini --paths prints them all.

PathWhat
~/.config/swov/configShared palette, read first
~/.config/browser-{mini,big}/configSettings
~/.local/share/wkview/<profile>/Cookies, history, search keywords, permissions
~/.local/share/wkview/download-dirs.tsvDownload rules (all profiles)
~/.cache/wkview/<profile>/Cache, safe to delete

--clear-data wipes the profile. --forget-permissions drops camera and microphone answers.

Config

key = value, # comments, colours as RRGGBB[AA]. The command line wins. Every key is also an option: --hl=ff8800. -c PATH reads one file only, -n reads none.

Safari version

WebKitGTK derives the Version/ token from its own release numbers, so 2.54 reports Version/60.5 - no Safari that ever shipped. Sites that look the version up print "Could not identify this version of Safari" and may take a fallback path.

safari_version = 18.6

That rewrites only the token and keeps the platform string and the rest of the agent as WebKit built it. --ua-safari instead replaces the whole agent with a macOS one; --ua-chrome and --ua-firefox avoid claiming to be Safari at all, which needs no upkeep.

Nothing can keep the number current on its own - it is one line to bump.

Patches

Video calls need three upstream fixes. They are real bugs in current releases, not configuration, and none is upstream yet.

FileApplies toWithout it
webkit-videorate-skip-to-first.patchWebKitGTK 2.52 / 2.54Own camera freezes or goes black, hundreds of frames per second, CPU pinned (WebKit PR 74373)
webkit-caps-normalize.patchWebKitGTK 2.54Camera modes listed as 640 x {480, 360} are ignored. Many laptop cameras get no 4:3 mode, so 16:9 with black bars
gst-glupload-null-meta.patchGStreamer 1.28 (gst-plugins-base)Web process crashes on a site's second camera request

Apply in the source tree, then rebuild and reinstall that package:

cd webkitgtk-2.54.0
patch -p1 < /path/to/patches/webkit-videorate-skip-to-first.patch
patch -p1 < /path/to/patches/webkit-caps-normalize.patch

cd gstreamer-1.28.x/subprojects/gst-plugins-base   # or the plain gst-plugins-base tarball
patch -p1 < /path/to/patches/gst-glupload-null-meta.patch

Add --dry-run first to check. Without the GStreamer patch, WEBKIT_GST_DISABLE_GL_SINK=1 avoids the crash at some CPU cost.

Check that they work:

  • Videorate: the WebRTC sample pc1 (below) encodes about 90 frames per
  • 3 s report, not hundreds.

  • Caps: --rtc-trace shows a 4:3 camera track (aspectRatio 1.333) on a
  • site that asks for one.

Video calls

browser-big repairs these WebKit problems by default:

RepairWhy
libnice ICElibrice finds no public address, so nothing connects past the LAN. ice = rice undoes it
VP8 firstWebKit encodes the first codec of its own offer and ignores the answer. video_codecs = native undoes it
Real SSRC and payload typeWebKit writes no a=ssrc lines. mediasoup sites get the values WebKit really sends
RTCRtpSendParameters.codecsWebKit requires it; some libraries omit it
Camera without soundA remote stream with silent audio is shown video-only, since WebKit's player waits for audio
Permission stateAnswered from remembered permissions, so sites see device labels
Camera frame rateWebKit only takes modes with the exact requested frame rate. A soft limit is dropped. cam_size_fix = no undoes it

--no-fix-webrtc turns off the SSRC, parameters and silent-audio repairs. --no-cam-fix injects nothing.

Permissions. A request asks at the top of the window: Enter allows, Esc denies, remembered per site. media = ask|allow|deny in the config.

Per machine:

# ~/.config/browser-big/config
audio = alsa                     # no sound server
mic_match = ThinkPad             # mic whose label contains this text
feature = OffscreenCanvas=off    # Zoom
web_compat = yes                 # Zoom: screen.orientation

mic_match / cam_match pick a device by label. mic_match overrides the microphone a site asks for. arecord -l lists microphones.

When a call does not work

browser-big URL --rtc-trace 2>&1 | tee /tmp/bb.log
LineMeans
sdpEach description, codecs as payload-type name
ssrc-real, ssrc-ws, pt-fixedThe server got the real SSRC and payload type
rtc-statsEvery 3 s: out- sent, far- server report, in-* received
video-stateEvery <video> with a source, camera or file: size, ct/dur, loop, seeking, frames shown, dframes and ddropped since last tick
stuck: trueOn rtc-stats or video-state: counters stopped moving
video-audio-splitA silent-audio stream shown video-only
codec-mismatchWe encode something the far end did not agree to
  • out-video.enc climbing, no far-video: the server drops our stream.
  • in-video.dec climbing, video-state.frames at 0: decoded, never shown.
  • in-video.fir climbing, keys still: no keyframe arrives.

A frozen picture, audio still playing. Grep for stuck. The receive path is checked at three points and stuck names the one that stopped:

stuckWhere it stopped
nothing arrivingNo bytes. Page or server stopped sending
arriving, no frame assembledPackets arrive, never form a frame
assembled, not decodingWhole frames arrive, decoder will not advance

A fourth point is the element itself: video-state with stuck: true and dframes: 0 while in-video.dec still climbs means frames decode and are never presented.

Supporting counters on in-video: recv frames assembled (-1 if WebKit does not report it), fdrop dropped, jbd/jbe jitter buffer delay and frames out, dectime total decode ms, frz/frzms freeze count and duration, rtx retransmits received.

The timestamp on the first stuck line is when the picture froze.

Without a server: browser-big https://webrtc.github.io/samples/src/content/peerconnection/pc1/ --rtc-trace. If that works, WebKit's WebRTC is fine and the problem is site-specific.

Camera: browser-big --list-cameras shows every mode each camera offers. Check ls -l /dev/video* and membership in group video.

Crash: attach gdb before starting the camera:

gdb -p $(pgrep -nx WebKitWebProcess) -batch \
    -ex 'handle SIGUSR1 SIGUSR2 SIGPIPE SIG34 SIG35 nostop noprint pass' \
    -ex continue -ex 'thread apply all bt 30' > /tmp/bt.txt 2>&1

browser-big options

Option
--rtc-traceEvery WebRTC step, stats, video elements
--media-traceEvery getUserMedia call and result
--media-debugVerbose media, permission and capture logs
--list-camerasCamera modes, then exit
--gst-debug SPECGStreamer logging, e.g. webrtc*:5
--gst-rank SPECAppend to GST_PLUGIN_FEATURE_RANK
--cam-shareA repeated request gets the camera already open
--no-micCamera only
--audio-alsaALSA instead of PulseAudio
--no-hw-decode, --no-vaSoftware decoding / no VA-API

When a page renders badly

Try one at a time; the first that helps names the layer:

browser-mini URL --no-jit          # JavaScript JIT
browser-mini URL --no-dmabuf       # WebKit's dmabuf renderer
browser-mini URL --no-compositing
browser-mini URL --no-gpu
browser-mini URL --gsk cairo       # GTK renderer (default gl)

--feature NAME[=on|off] sets a WebKit runtime feature, --list-features lists them. --gl-info checks the graphics stack.

These are turned on here, because WebKit ships them off outside Cocoa and a page that stores data cannot see the API at all without them:

featurewithout it
StorageAPInavigator.storage undefined
StorageAPIEstimatenavigator.storage.estimate() undefined
FileSystemnavigator.storage.getDirectory() undefined
AccessHandle + FileSystemWritableStreamcreateWritable() absent, so OPFS is read-only

createWritable needs both of the last two: it is declared [EnabledBySetting=AccessHandleEnabled&FileSystemWritableStreamEnabled], so one alone changes nothing. --feature StorageAPI=off still wins.

When a gallery of GIFs freezes

It does not any more. WebKit used to suspend a muted video that scrolled out of the viewport and resume it on the way back, by setting the GStreamer pipeline's state from the main thread inside the scroll's own layout. If the pipeline's sinks were still prerolling they held the state lock and waited for that change to finish, so the main thread blocked on the lock and the page never answered another key.

Every "GIF" site serves muted autoplay videos, so a dozen items were enough. The process slept rather than spun, and no watchdog saw it.

The suspend is off by default now. Offscreen videos keep decoding, which costs CPU on a long scroller. --media-suspend, or media_suspend = yes, hands it back to WebKit.

When a looping clip flickers or sticks on one frame

A second, unrelated bug with the same pages. WebKit's loop attribute wedges on a short clip: it seeks back to zero at the end and the seek never finishes, so currentTime stops, seeking stays true, and the element keeps showing one stale frame.

A seek from script completes every time. So the attribute is taken off and the loop runs in the shim, which is on by default. Measured on a 1.7 s clip over 24 s:

loopscurrentTimeseeking
default12advancingfalse
--no-loop-fix1stuck at 0true

--rtc-trace logs a loop-fix line per element. --no-loop-fix, or loop_fix = no, leaves it to WebKit.

Native loop fires no ended event and this does, so the shim stops the event rather than letting a page see one it never expected.