Spent about nine months on this, so sharing some details. The goal was simple: I wanted HTML/CSS/JS for game UI, but I didn't want Chromium inside the game. A browser has to render any page on the internet. Game UI only renders my page, which ships with the game. So most of a browser isn't needed: network, origins, history, cookies, process isolation and so on.
What I took: lexbor for HTML parsing, V8 for JS, Yoga for flexbox, Skia with skparagraph (HarfBuzz, ICU) for text and raster. The DOM, the CSS cascade and paint order I wrote myself, around 20k lines of C++20. Own DOM because I need computed style, layout box, dirty bits, listeners and the JS wrapper right on the node, otherwise every frame is hash lookups. Own cascade because lexbor's css module knows about 45 properties, and border-radius, box-shadow, transform, gap etc come out as raw tokens. Funny thing, the cascade ended up the biggest module, 5,800 lines, more than layout and paint together.
There's no copy into Unity. Skia's GrDirectContext is created on Unity's own D3D12 device and command queue (IUnityGraphicsD3D12v8, plugin event with kUnityD3D12GraphicsQueueAccess_Allow). The texture is a committed resource with ALLOW_RENDER_TARGET | ALLOW_SIMULTANEOUS_ACCESS, wrapped in an SkSurface, and C# gets it through Texture2D.CreateExternalTexture. So Skia draws right into the texture the RawImage samples, and sync is just command order on one queue.
The annoying part was resource states. Unity doesn't say anywhere what state it expects an external texture in, and Skia's D3D backend ignores MutableTextureState, so after flush the resource sits in COMMON. With simultaneous access D3D12 promotes it implicitly when Unity samples it and decays it after ExecuteCommandLists. It works, but I only believed it after a run with the debug layer on. That run also found one real bug, a SampleDesc.Quality mismatch from the default fSampleQualityPattern in a Skia struct. One line fix. Zero D3D12 errors now.
Threads: Unity main thread only does the C# API, input and messages. A runtime thread does events, timers, V8, style, layout and records an SkPicture. Unity's submission thread replays the picture into the surface and submits. Between threads there's only the immutable SkPicture (last one wins) and bridge messages. The DOM has to be synchronous from JS (set textContent, read it on the next line), so the V8 isolate lives on the runtime thread only.
What I underestimated was damage tracking. A frame is published only if something changed, and only the changed rect is repainted. The painter remembers where each box was in device pixels and compares with the previous frame, old and new rect both go into the union. 800x600, software raster: an idle menu went from 22.7 ms per frame, with every frame published, to 0 ms and 24 frames out of 301. A HUD with one animated element went from 15.9 ms to 0.115 ms, because it repaints 22x22 instead of the whole view. In our co-op game we then cut the HUD into 11 small views instead of one full-screen view. At 1080p on CPU raster that's 282.6 ms -> 9.7 ms per frame, but texture memory went from 7.9 to 15 MB.
Bugs I still remember:
The PLAY text sat outside its button. Yoga measures with trial widths up to a million px, the paragraph stayed laid out at that width, and text-align: center centred it somewhere far to the right. You have to lay the paragraph out again at the final width.
A button 245 px wide instead of 149. The anonymous inline box inherited the parent's style and added padding and border a second time.
The damage rect was always full screen. kDirtyPaintSelf was never cleared, and under that the damage function returned early on full repaints and didn't save bounds, so on the next frame every box looked new again. That one took me a while.
Also, quite often the test was wrong and not the engine. Negative z-index really does paint above the parent's background (CSS 2.1 Appendix E). I check the spec first now.
Missing: grid, float, calc(), custom properties, @media, ::before/::after, :nth-child, plus table, select, canvas, video and iframe. The fast path is Windows x64 + D3D12 only, other APIs fall back to software raster. No input for world-space UI yet. Pages have no network at all. The repo lists 33 deviations from browsers, e.g. the caret doesn't blink (two repaints a second per field, no thanks) and setTimeout(fn, 0) means next frame, because timers run on the game clock.
310 native tests with pixel goldens, 46 PlayMode tests on a real D3D12 device. v0.9, Apache-2.0.
https://github.com/Rovniy/xploit_game_ui
If you did external D3D12 textures in Unity differently, I'd like to hear how you handled the resource states.