๐Ÿ–ผ๏ธ

I Put HTML-in-Canvas in My Game. Then Turned It Off by Default.

Tags
Blosharper
GameDev
Electron
WebDev
Description
An experiment with WICG's HTML-in-Canvas to draw Blosharper's DOM UI into a canvas. It traces better image quality, unequal performance comparisons, and missing content. At the last recorded check, HIC remained experimental and disabled by default.
Published
Published Aug 31, 2026
On this page
HTML-in-Canvas (HIC) is a WICG proposal for drawing HTML and CSS content into a canvas. I tried it in Blosharper to keep the existing DOM-based interface and its layout while moving the final image into a canvas rendering path, where I could control how the pixels were drawn.
The image quality improved, but that did not establish a performance gain. Electron changed at the same time, and the HIC path skipped some visual effects, so the comparison conditions differed. Later checks found character portraits missing even while the rendering loop was running normally. This post follows the tests that examined those comparison conditions and the missing output.
HIC had been used as the default, but by the last verification recorded here it was an experimental option, disabled by default. The existing renderer was the default path, and the cause of the missing content was still unresolved.

Why I tried it

For this experiment, I used drawElementImage(), enabled through an experimental flag in Chromium. The API draws DOM elements laid out by the browser into a 2D canvas.
Blosharper already has an HTML-based interface. I wanted to keep that layout while controlling how the finished screen became pixels. My HIC path draws the screen into a canvas, giving the game's pixel rendering a different route from the existing SVG-based approach.
There was a visual improvement worth pursuing. It was enough to implement the path, test it, and try it as the default. The problems appeared when I started treating that improvement as evidence for other benefits.

Two changes, one apparent improvement

Around the same time, I moved from Electron 42 to Electron 44.
That meant two substantial things changed together: the runtime and the rendering path. In long Steam Deck sessions, an old symptom stopped appearing: effects that had previously caused stuttering were running more smoothly.
I could say the new build behaved better in those sessions. I could not say HIC caused it. Later runs with Electron 44 and HIC disabled also avoided the old frame drops. That weakened the case for crediting HIC and pointed toward the runtime upgrade instead.
I had no basis for saying HIC fixed a memory leak or solved long-session stability.

The comparison was not drawing the same thing

There was another problem with comparing HIC on and off.
In the implementation at the time, enabling HIC skipped some SVG effects. A CRT-style distortion effect and a pixelation filter were not applied on that path.
Pixelation lab for comparing HTML-in-Canvas with the existing SVG filter. The SVG filter is selected in this screenshot.
Pixelation lab for comparing HTML-in-Canvas with the existing SVG filter. The SVG filter is selected in this screenshot.
So an apparently smoother HIC run could be doing less work because part of the presentation was missing. It was not necessarily producing the same image more efficiently.
Before comparing frame times, I needed to check whether both paths were actually rendering equivalent content. Without that, a performance number would hide a visual difference that mattered to the game.

A grid to check what actually got drawn

Drawing a screen with HTML-in-Canvas creates a problem for testing. The screen's elements still exist in the DOM, so automated tests that check whether an element exists or can be clicked all pass. Those tests do not see what was actually painted into the canvas. In August 2026, every automated test passed while the game board was visibly broken on screen.
So I built a separate test page to compare the rendered output directly.
HIC fidelity test grid. The left side is drawn with HTML-in-Canvas; the right side renders the same markup as ordinary DOM content.
HIC fidelity test grid. The left side is drawn with HTML-in-Canvas; the right side renders the same markup as ordinary DOM content.
The page has two copies of the same tile grid. On the left, HTML-in-Canvas draws it into a canvas. On the right, the same markup stays in the ordinary DOM as a reference. The tiles share a blue base color, with one feature changed at a time: opacity, 3D transforms, filter, backdrop-filter, blend modes, masks, shadows, text, SVG, images, and nested 2D and WebGL canvases. If a feature disappears on its way into the canvas, that tile changes color relative to the reference. The difference is visible at a glance, and the page also reads the canvas pixels directly to record their deviation from the reference color.
The first tile has no effects. If that baseline tile is wrong, the test itself is wrong, so I check it before interpreting the other results.

Drawing one frame and keeping it moving

The first version of the grid only compared static tiles. That left a problem it could not detect. In the Electron app at the time, the cherry blossoms appeared on screen but did not move. The first frame was drawn correctly, but later updates did not reach the canvas.
I added moving tiles to test that separately. CSS animations, images, 2D canvases, and WebGL canvases keep changing, and the test compares samples taken at intervals to see whether the pixels actually change. This test has a reference tile too. If it says an ordinary DOM tile is not moving, something is wrong with the measurement. I check that the reference is moving before concluding that another tile has frozen.
I also record how many draw calls succeeded and how many failed alongside the results. Calling a drawing function and producing an image are different facts.

What the grid showed

Running the grid across Chromium versions in August 2026 revealed a clear difference.
  • In Chromium 148, used by the shipping build at the time, encountering an element with backdrop-filter caused everything after it in the drawing order to disappear. Only 15 of the 33 static tiles rendered correctly. This matched the missing middle of the board in the game. Nested 2D and WebGL canvases drew their first frame, then froze.
  • In Electron 44, which used Chromium 152, all 33 static tiles rendered correctly, and every moving tile kept updating.
Those results gave me a reason to try HTML-in-Canvas again after moving to Electron 44.
The screenshot above should be read separately from those August measurements. Most CSS tiles look similar to their DOM counterparts, but differences remain, including the edges of the backdrop-filter tile. All six nested canvas tiles are blank on the left: three 2D canvas variants, WebGL, animated 2D, and animated WebGL. Character portraits and dice use WebGL canvases, while the cherry blossoms use a 2D canvas. The missing content points in the same direction as the blank portraits with HIC enabled, which the next section covers. The grid shows what failed to appear, but does not establish why.

October 2026 update: the renderer was running, but the portraits were missing

I revisited HIC when testing Electron 45.1.0. In a macOS build tested on Apple M4 hardware, enabling HIC left character portraits and nested canvas content blank.
Some of the lower-level checks looked fine. The portrait's WebGL context existed and did not report itself as lost. The HIC rendering loop was active. Those facts did not establish that the portrait reached the screen.
The visual checks caught the failure. Detecting an API, creating a context, or seeing draw calls advance only answered part of the question. The game still needed to display its characters.
The retest established a rendering failure in that configuration. It did not establish whether the underlying cause belonged to Chromium or to my use of it.

Status as of the 30th

Blosharper has moved to Electron 45.1.0. HIC remains an experimental option, disabled by default, with the rendering issue still open.
The visual benefit is still a reason to keep investigating. It is not enough to make players use a path that can leave character portraits blank.
For now, the existing renderer stays the default. Any future comparison needs equivalent effects, checks of the actual game screens, and enough separation between changes to explain the result.
The HIC implementation remains in the game so I can test it again. It is not the default players use.