A groundbreaking new initiative, dubbed Carbonyl, is revolutionizing text-based web browsing by ingeniously adapting the Chromium engine to render web pages directly within a terminal emulator. Instead of displaying pixels on a graphical window, Carbonyl converts every aspect of a web page into a rich tapestry of Unicode block characters and ANSI color escapes, providing a fully interactive experience complete with text selection and input capabilities.

Most existing terminal browsers like w3m or Lynx achieve their functionality by parsing HTML and reconstructing the layout. Carbonyl, however, takes a distinct approach by harnessing the authentic Chromium engine. It cleverly intercepts Chromium’s internal rendering processes, specifically Skia’s bitmap and text-drawing devices, to capture the visual output. This method ensures that the precise layout, CSS styling, JavaScript execution, and even browser extensions function exactly as they would in a standard Chrome browser, simply without the graphical user interface. The captured output is then dynamically translated into terminal control sequences.

The rendering pipeline is a sophisticated three-step process:
1. HTML to Skia Bitmap: Chromium’s renderer initially draws web pages into an offscreen SkBitmap. Carbonyl intervenes here by employing a custom HostDisplayClient and shared memory mapping, allowing it to capture this bitmap data across different processes (GPU, renderer, browser).
2. Bitmap to Terminal Blocks: Each terminal cell is represented by the U+2584 lower half block character, leveraging 24-bit ANSI colors. Carbonyl assigns the top pixel’s color to the cell’s background and the bottom pixel’s color to the foreground. This process is optimized by batching calls to minimize cursor movement.
3. Text Capture: To ensure crisp, selectable text, a TextCaptureDevice is inserted into Skia’s pipeline. This device intercepts glyph runs, converting glyph IDs into their corresponding Unicode characters and issuing ANSI codes to render them directly, rather than as mere bitmap blocks.

Interaction with Carbonyl is seamless, mirroring a traditional browser experience. It interprets mouse and keyboard inputs through ANSI Device Control Sequences (DCS). These sequences are then fed back into Chromium’s input system, enabling actions such as clicks, scrolling, and text entry, all managed on the main thread via BrowserMainThread::PostTask.

Initially, Carbonyl presented performance challenges, running at approximately 5 frames per second (FPS) with around 400% CPU utilization on contemporary hardware. However, two significant optimizations dramatically improved its efficiency:
* LoDPI Scaling: For terminal display, the display scale is aggressively reduced to 1/7, effectively shrinking the pixel grid by a factor of 49.
* Threaded Compositing Hacks: By deactivating disable-threaded-scrolling and disable-threaded-animation, rendering operations are consolidated on the main thread, circumventing the overhead of costly cross-thread coordination.
These adjustments reduced idle CPU usage to nearly zero, with scrolling performance stabilizing at about 15% CPU.

Community feedback has highlighted the novelty of a “true Chromium-powered terminal browser.” While some performance concerns persist regarding its viability for daily, heavy use today, its potential applications are considerable. Developers foresee its utility in remote server environments, for previewing Continuous Integration (CI) logs, in low-bandwidth scenarios, or as part of highly portable development setups. Feature requests include true-color detection, customizable block resolution, and SSH-friendly input modes.

Carbonyl stands as a compelling demonstration of how versatile modern browser engines can be when ingeniously integrated with terminal graphics techniques. It offers unparalleled web compatibility, preserving JavaScript, CSS, and extension functionality. Furthermore, it maintains fully selectable text, crucial for copy/paste and accessibility. This project paves the way for new possibilities, from GUI-less demonstrations and remote interactions to embedded deployments in resource-constrained environments. For anyone fascinated by browser internals, terminal graphics, or the convergence of graphical and command-line interfaces, Carbonyl provides an insightful and practical case study.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed