Besides technical complexity, large projects almost always bring organizational complexity with them. When the task list is endless and resources are not, you have to think ahead. But even with careful planning, you can still end up in a situation where things are happening and yet nothing comes of them.
Hardware acceleration is without question a useful and interesting feature for a browser. It was interesting to explore and interesting to work on for a while—and then to set aside until even more essential things were up and running. But the better the browser worked, the more trouble hardware acceleration caused. Crashes, glitches, hangs: some were fixed in a couple of lines, others still need investigating. In the meantime, the browser could be made to detect failures and switch to software mode. A job for a couple of evenings.
Three weeks later I am nursing my bruises, and the feature is nowhere near done. Why?
Because that is how it goes. Just a little more, just a bit further… you fix font unloading in DirectWrite, you find leaks in original code that was never tested. Then the tests show something odd, and it turns out that on Linux, Quix is initialized and torn down differently than on Windows…
The more problems got solved, the more of them appeared. The horizon receded exactly as fast as I approached it. By the second week, the effort sunk into the fixes had already exceeded the original estimate several times over. I know about the Concorde effect and usually know when to stop. But every time there was one, just one more necessary little patch left—and I kept going.
When a hundred “little” patches had been gathered together, I took a look at the whole heap. It was bad: complicated, unwieldy and unreliable. Switching from hardware to software rendering somewhere halfway through drawing to a canvas required reworking and complicating a whole pile of other submodules, and there was still no guarantee it would work.
That kind of complexity would be justified if I were writing, say, control software for a spaceship, a submarine or a nuclear reactor. Or, at a stretch, an operating system, where screen output has to work by hook or by crook. But this is a client application; if your graphics card fails while you are browsing, a half-drawn page will be the last thing on your mind. A browser does not need a fallback to software rendering; it is enough to show a crash notice offering to switch to software mode after a restart—and that is what I should have thought of in the first place.
The new framing made the task an order of magnitude simpler. The work started over from scratch: the useful fixes were carefully carried over, and everything else was ruthlessly thrown out. Even so, the feature is still far from finished, but once the horizon is nailed down, it is much easier to reach.
For testing and measuring Carakan’s performance I have already used JetStream2. JetStream3, the more current version of the benchmark, still refuses to load in Otium. The search for the cause led to the Fetch subsystem.
Its implementation was incomplete from the start: no Streams support (added a little later) and no caching. I assumed this would not cause problems, since the source of a resource is hidden from its consumer. That is indeed true, but it turned out we still have to come to terms with the consumer—even if we have no intention of keeping our side of the deal. While loading, JetStream3 called Fetch with additional caching options for the request. Otium did not understand what was being asked of it—and that was where loading stopped.
Per the standard, fetch() accepts not only an address but also a set of options, for example fetch(url, { cache: "no-store" }). This resembles the way servers control the parameters of HTTP requests through headers. There are many possible options, but right now we only need two:
fetch(url, { cache: "default" }): the usual HTTP cache rules.fetch(url, { cache: "no-store" }): do not read from the cache and do not store anything in it.The problem here is how to make Fetch get along with the browser cache. The cache module is tied to URIs quite literally, using the normalized address as the resource key:
URL_Rep is the “super-object of an address” that holds everything the browser knows about a resource; URL_Store is the registry of these super-objects. When the engine needs an address, it first looks it up in the registry: if found, it hands back the existing URL_Rep with its copy and state; if not, it creates a new one and registers it.
ETag is a standardized header, a unique tag for a resource, invented specifically to make caching easier for browsers. The browser keeps this tag next to its copy of the resource, and when the copy goes stale, instead of downloading the file again it asks the server: “I have version a1b2—is it still current?” (the If-None-Match header). If it is, the server replies with a short 304 Not Modified without a body, and the old copy counts as fresh again. If not, it sends the new file with a new tag. Last-Modified works the same way, except that instead of a tag it carries the modification date (the question is asked with the If-Modified-Since header).
Repeated access to a resource looks like this:
An ordinary cache works on a simple rule: one address, one URL_Rep, one correct response. All requests are made by the browser and are always the same, so both cookies and request settings can safely live in the same shared object. With Fetch, that does not work: the request is built by a script, and the server may return different responses for the very same address, for example:
Accept-Language: ru, script B for en. The server returns the Russian and the English version from the same address./api/item/42 returns HTML for Accept: text/html and JSON for Accept: application/json.Accept-Encoding.default is willing to take a copy; no-store insists on going to the network and storing nothing.How does a server signal that a response depends on the request? With the Vary header: Vary: Accept-Language means “this response is only good for those who sent the same Accept-Language.” So the cache has to remember not only the response itself but also exactly which request it was obtained for—and hand the copy out only to a matching request. And a POST to the same address means the data on the server has most likely changed, so every response stored for that address needs to be revalidated.
To keep the settings of one request from mixing with those of another, each fetch() works on its own private URL_Rep, bypassing the registry. Giving up the private object is not an option—cookies and access rights would get mixed up. So private objects have to be able to use the shared ones without spoiling anything in them. To that end, the cache has learned to:
Vary headers as the current request? If so, the request reads the copy and never touches the network. To make this possible, every response now carries a record of exactly which request it was served for.If-None-Match set to the ETag of the shared copy. A 304 response extends the life of the shared copy; a 200 replaces it.URL_Rep is stripped of everything private and becomes the shared entry for that address. From then on, the next fetch(), an ordinary image and a stylesheet alike can use it.As always, this is a simplified description. Beyond the basic logic, there were plenty of dull problems to solve, such as which parts of the cache should be kept on disk and which only in memory, or what to do if the user clears the cache in the middle of a request. And, as usual, one solved problem opened up a dozen new ones: now the remaining cache modes have to be implemented, and, while we are at it, the entire Fetch standard.
That said, JetStream3 still did not work and will not—it also needs WebAssembly, and the engine is a very, very long way from supporting that.
It is remarkable that even after all these years some people still use Opera. There is a whole infrastructure of crutches for it, such as TLS proxies, user JS/CSS and the like; users simply refuse to let Opera die for good. Zero percent judgment, one hundred percent understanding.
I have noticed that even when people resign themselves to moving to other browsers, they often keep using M2, the mail client built into Opera.
Frankly, I am not a fan of M2. I do not think it is bad—I have just never used it. For the same reason I had no plans to dig into its code any time soon, but the first community patches to come in were for the mail client, and that deserves a mention. Here is what was fixed in M2 by joint effort:
Send patches! Patches are good!
The core mail protocols are set in stone, but mail services keep evolving. Major mail providers are gradually abandoning password login: Microsoft has turned it off for Outlook and Exchange Online, Google has kept only “app passwords,” and OAuth 2.0 has become the normal way to sign in. IMAP itself has gained extensions that save time and traffic: the already mentioned MOVE, CONDSTORE and QRESYNC (fast synchronization, where the client asks only “what has changed since last time?”), SPECIAL-USE (the server itself says which folder is the trash and which holds sent mail), COMPRESS, and UTF-8 support in addresses and folder names. The proprietary quirks of Gmail and Exchange have to be taken into account as well—and there are quite a few of them.
Research into the client itself and further work on it are still waiting their turn, as is the story about them.
The DOM—Document Object Model—is how a page looks to JavaScript. The browser parses HTML into a tree of elements, and a script sees that tree as objects: document.body, element.children, node.appendChild(), events, styles, forms. Everything that makes a page “alive” happens through the DOM.
To save resources, Presto does not expose its entire internal representation of the tree to Carakan at once. When a script first accesses a node (for example, document.body.firstChild), a wrapper is created for that node, providing a JS object on top of the C++ object HTML_Element.
The main way Presto’s DOM lags behind is in how exactly a script gets firstChild. GetName is essentially a big switch that calls the right C++ function; this is fast and reliable—as long as the script only reads properties. The modern standard for describing interfaces, Web IDL, works differently: every property is a “getter” function that lives on a prototype (Node.prototype, Element.prototype…) and can be taken out, overridden, called on a different object or inherited. Prototypes underpin the Custom Elements standard (the closest relative of Shadow DOM), and frameworks make heavy use of them. Presto does have interface prototypes, and methods do live on them, but attributes like firstChild have no getters on the prototype.
The rest is hundreds of new interfaces and methods that have appeared over the years. The total amount of work is comparable to the Carakan upgrade, but there is no way around it. YouTube, for one, will only work with a modern DOM: its front end is built on the Polymer web components library. A browser without YouTube is hardly worth having, is it?
Work on the new DOM is in full swing, and I will say, very cautiously, that I will be glad if I manage it within a month, but I will not be upset if I do not.
How cross-platform is Otium?
I would not be asking myself this question right now if it had not come up in several discussions. Users have even started patching builds for Windows 7, and that got me curious too.
Opera’s base sources are designed to build for any Windows that was current at the time, from Win2K to Win8. Support for Windows 9x was dropped in Opera 10.54, a couple of years before 12.15. With the “all we need is C++” and “a new platform in a month” paradigms, it would seem that nothing should stop Otium from running anywhere except Plan 9. In practice, things are different.
First, the language level has been raised from C++98/C++03 to C++20. Systems whose toolchains stopped evolving at older versions of the language will need adapting, but that is solvable.
Second, every type of OS needs its own platform layer. The browser takes relatively little from the operating system, but even that has to be spelled out.
Third (and most important): third-party code. SQLite, ICU4C, OpenSSL, GStreamer and everything else that has been updated. That code also has to work on the system the port targets, or else you have to bolt on whatever equivalents are available (which is what Opera did whenever it could).
But all of this is theory, and what interests us is practice: what can be done without changing the toolchain, without diving deep into the platform layer, and without burning more than a million nerve cells?
One of the “unlucky” versions of Windows, which lived out its days between the incomparably (and deservedly) more popular Windows XP and Windows 7. It interests us as a significant milestone in the evolution of Windows: new APIs, new capabilities, a new driver model. The next such milestone would only be Windows 8 (2012), and whatever builds and runs on Vista will also work on Windows 7, and on later versions too.
Building the browser’s own sources caused no problems, even though I was using MSVC from Visual Studio 2026. The declared minimum target platform for this version is Windows 10, but there is a catch: that applies only to the standard library and the runtime. Since Otium uses neither, this is not a problem.
Third-party components, however, cannot be expected to behave the same way. The first thing I ran into: ICU requires certain WinAPI functions to be present. If the loader does not find them, it reports an “entry point not found” error and the file will not start, even if those functions are never actually called.
These functions are GetSystemTimePreciseAsFileTime (introduced in Win8) and ResolveLocaleName (Win7). The first one ends up in the import table by way of the STL; the second is used directly in ICU’s code.
Changing the toolchain for a couple of functions is, well, meh. Making the build patch binaries is not a great solution either. But you can give the linker your own definitions of these functions, so that they are checked only at the moment of the call, and if they are unavailable, the call takes a fallback path. For GetSystemTimePreciseAsFileTime, substituting GetSystemTimeAsFileTime will do (the same meaning with a harmless loss of precision), and for ResolveLocaleName, a wrapper that returns the U_UNSUPPORTED_ERROR error. Otium does not use this function at all, so the approach causes no problems.
This trick is nothing new: Opera already used it to support Win2K and XP when building with VS 2010. The functions were different, but the idea was the same.
But once running, the browser will still have trouble playing media. GStreamer looks for CreateFile2 (Win8), and it also needs the api-ms-win-crt-*.dll library from the Windows SDK distribution, which may be missing on older versions of Windows.
The library is the easiest part—just put a prebuilt copy next to the program. The function import could be handled the same way as with ICU, but here there is no need: GStreamer’s code already has a conditional branch:
static HANDLE
gst_plugin_loader_client_create_file (LPCWSTR pipe_name)
{
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
CREATEFILE2_EXTENDED_PARAMETERS params;
...
return CreateFile2 (pipe_name, GENERIC_READ | GENERIC_WRITE, 0, OPEN_EXISTING, ¶ms);
#else
return CreateFileW (pipe_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
#endif
}
so for Vista it is enough to build the library with the -D_WIN32_WINNT=0x0600 flag.
On closer inspection I found a few more places like this; the fixes there are similar.
Apart from these changes, the resulting code will be identical to the code for Windows 8+—but that does not mean it will work exactly the same way. Adding Vista builds to the build system cost me nothing, but testing and fixing them—no, thank you.
Here is an example: to check that the build worked, I used QEMU with a Vista image, and Otium started and rendered the test pages without any trouble. In VMware, however, Otium crashed while trying to call K32EnumProcessModulesEx from KERNEL32.dll.
That call appears nowhere in the source code, neither in the browser (which uses EnumProcessModules from PSAPI.DLL) nor in the third-party components. The function itself only appeared in Windows 7, so, all in all, yet another mystery.
Long story short: the import comes from the OpenGL driver of VMware’s virtual graphics card (the same driver serves Win7 and Vista). Otium, meanwhile, probes for OpenGL to see whether hardware acceleration is available, and trips over someone else’s bug; interestingly, the fixes in the hardware acceleration branch catch this case correctly—but the branch itself is still far from finished.
Let us go one step further down. XP remains popular among retro enthusiasts, and I know how much they suffer without a modern browser. Can we give them what they want? Naturally, we will only consider versions with the latest service packs: enthusiasm is all well and good, but one has to draw the line somewhere.
The problems start as early as the build. The last toolset with XP support is v141_xp from VS 2017; VS 2019 and 2022 can still install it, VS 2026 no longer can. And I really did not want to add yet another version of Visual Studio to the environment.
Can the current VS 2026 somehow be made to build code for XP the same way as for Vista? Yes, if you write stubs and alternatives for every function that is needed. For Vista there were five; for XP there are dozens.
Fortunately, the creators of YY-Thunks have already done all the work! It is an object file that is linked into every module and does exactly what our Vista stub does, only for hundreds of functions. Each such function is looked up in the system on its first call, and if it is not there, the call goes to the library’s own implementation. Do take a moment to give the project a star on GitHub!
Compared to that, the remaining tweaks are trivial. The /SUBSYSTEM:WINDOWS,5.01 switch writes subsystem version 5.01 into the PE header for x86, and 5.02 for x64. A curious fact: these are the minimum versions the linker allows, and an attempt to specify 5.00 results in an error.
The next problem: TLS (thread-local storage).
Otium.exe is a launcher; the engine itself lives in Otium.dll and is loaded via LoadLibrary. The XP loader cannot initialize implicit TLS (__declspec(thread) variables) in a DLL loaded this way. Microsoft says so plainly in its documentation, and Opera’s developers knew it: thread data in Opera.dll was handled by a custom WindowsTLS class built on TlsAlloc. I missed this point in my own changes when I introduced __declspec(thread) variables to store the stack bounds of OpPseudoThread.
Switching to WindowsTLS solved the problem. The remaining implicit TLS, added by the runtime, is covered by YY-Thunks: it has its own DLL entry point that initializes TLS by hand. Thread-safe initialization of static variables (/Zc:threadSafeInit-) is disabled in the XP build because it relies on the same TLS.
Moving on to the library whose portability worried me most. Had it not worked out, all the effort would have gone to waste. I am talking, of course, about OpenSSL.
Regular Windows builds use a prebuilt static OpenSSL 3.6.3, which imports SRW locks, fiber functions (the async subsystem) and other functions missing from XP. Backporting all that held no appeal for me whatsoever.
But even the very latest OpenSSL sources still contain code for XP! If you build with the _WIN32_WINNT=0x0501 flag, locks are built on good old critical sections, and random numbers come from CryptoAPI instead of BCrypt. The async subsystem is disabled altogether (no-async); the browser does not need it. Rebuilding OpenSSL meant bringing Perl back and adding NASM, but it was worth it. A modern, secure WEB on XP—just imagine it!
Next library: ICU. The official minimum for ICU 78 is Windows 7; the last version of ICU to support XP was 58. Rolling back to ICU 58 would have meant rolling back Intl as well. YY-Thunks came to the rescue again: with its stubs, the library built and, it seems, works. I say “it seems” because at the time of writing I had not run any tests on either Vista or XP.
But surely it cannot all be this easy? There must be some problems after all?
There are: GStreamer dropped XP support long ago. Strictly speaking, the library does not support Vista either, but there we got off lightly. For XP, a modern GStreamer would have to be ported and debugged separately.
There are other options, of course. Adapting older versions, looking for other media backends—you can always come up with something, given the desire, the resources and the time; for now, though, on XP multimedia is absent by design.
As, probably, are other things we have been spoiled with over the past quarter century. For example, modern systems ship fonts covering almost every Unicode character, emoji and other glyphs. XP has none of that, so Otium will draw empty boxes. Or, for example, XP has no Direct2D or DirectWrite, but here we can thank the original code, which has a fallback to GDI.
And that is only what I happened to notice. It would be interesting to find out what else is broken on old operating systems—but some other time. Maybe in my next life.
You might ask: why XP and not Win2K? The two systems are very close, and Opera supported them on an equal footing for a long time.
Because this is where I draw the line: beyond it, things stop being interesting. YY-Thunks does come in a Win2K flavor, but without export tables, which means there is no way to verify the substitutions. The VS 2026 linker will not write the PE subsystem version 5.00 that Win2K requires into the binary, so a hack would be needed. It is harder, but not fundamentally different, and an XP build fully satisfied my curiosity.
It is quite possible that extended kernels such as Blackwingcat’s Extended Kernel or One Core API would let builds for newer systems run on old ones, but I will leave that necromancy to those who are into it. Especially since now I want to take a look at…
…but who cares what I want? I have seen too many projects (and, let’s face it, done this myself) where the developers got carried away with interesting things of tertiary importance, and everything fell apart. With an effort of will, I am shelving experiments in this direction—for now.
I must say these experiments turned out to be unexpectedly useful. The original code was designed to work everywhere, and the WindowsTLS episode reminded me of that. So experiments in this direction have a legitimate place on the project roadmap; I intend to come back to them from time to time.
I want to address everyone who is gradually joining the project—as contributors, testers or simply interested onlookers. I understand your impatience, and I understand the wish to see the problems that get in your way solved first. I wish I had the resources to do everything at once. To publish a weekly poll along the lines of “what do we do next?” and have you choose between a port to Windows 3.11 and IPFS support. Or better yet, never to have to choose at all, and have every feature appear at once.
Reality has its limits; I do what I can, step by step. It is quite likely that someday I will start accepting certain bug reports—once Otium is ready enough.
For now, the near-term plan covers everything described in this installment of the Archaeology: the DOM, Fetch, hardware acceleration…
…and maybe something else.