Repository navigation
Under the hood of WSA-Next - hardware, workflows and the physics of building Android 15 #44
wesmar
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Some notes from the author before the holidays. The plan was a St. Nicholas Day surprise with everything stable, but time ran out: the physics of compilation, hardware and diagnostics caught up with me. Below: what the workshop looks like, where this came from, how a regular laptop handles the load, and where most of the time goes when you build on top of closed-source WSA.
Note
WSA-Next is not built on a server farm or a corporate CI with 64 cores and a 10 Gb/s fiber line. All of Android 15 for x86_64 and ARM64, the Linux 6.18 kernel, the host graphics stack (ANGLE, Vulkan-Loader, Mesa Dozen) and the Windows installer are built on one laptop, with an external USB drive and a 5G link.
1. From
WSAPatchto a WinAPI host: old-school REThe last month is when everything came together into a working system, but the plan goes back to spring. It started in May, when WSA from MustardChef's builds stopped booting on my Windows 11 26H1 machine and I wrote wesmar/WSAPatch in assembly: a small binary patcher that applies two patches to
WsaClient.exeagainst theSTATUS_STOWED_EXCEPTION 0xC000027Bcrash.From then on I took the images apart, read the logic of
WsaClient.exeandWsaService.exe, traced system calls and mapped every boundary between Windows and Android. The long-term goal: drop Microsoft's closed and abandonedWsaClientandWsaServiceand run on a host layer written in plain WinAPI on top of HCS, vsock, D3D12/Vulkan and/dev/uinput.In a big corporation a project like this keeps a team of well over a hundred people busy for years, with managers, planners, coffee meetings, priority debates and fixing bugs other departments brought in. Alone you can take a much shorter road, because the whole picture fits in one head. Thirty years of hands-on work help a lot: DOS, Windows NT 4, Iczelion's Win32 ASM tutorials, PLD Linux, LILO, Symbian. So do the early years in Polish reverse-engineering groups like CrackPL, CookieCRK and similar crews, and the habits from the SoftICE era: API names and wrappers change every few years, machine code and the stack stay the same.
2. External 1 TB USB-A 10 Gb/s drive and my own
ext4.sysdriverThe AOSP 15 source tree,
out/for two architectures, Google Play emulator images, Linux 6.18 kernel builds and packed releases take 537 GB of 916 GB right now. On the laptop's internal SSD that would be half the drive next to Windows. So the whole workshop lives on an external 1 TB NVMe in a Realtek RTL9210C enclosure on USB-A 10 Gb/s, formatted as ext4.Why not NTFS for AOSP
0700/0600permissions for release keys, andsecurity.selinuxextended attributes when editingvendor.vhdxwithdebugfsande2fsck.drvfsoverhead: an Android build hits hundreds of thousands of small files andstatcalls. Throughdrvfsover NTFS that is slow, and builds break in random places.ext4.vhdxkeeps growing on the system SSD, and every time Windows has to look at or serve a release, gigabytes get copied back and forth.Two worlds, one disk, my own
ext4.sysTo avoid two 500 GB copies and still get native speed on both sides, I use my own Windows kernel driver wesmar/Ext4,
ext4.sys:F:\byext4.sys. Local IIS servesF:\WSA\releases\android-15through a junction, so I test the installer, signmanifest.cat, look intoout/and check hashes without copying a single megabyte.build_on_f.ps1takes the disk offline in Windows and attaches it to WSL2 withwsl --mount \\.\PHYSICALDRIVE1 --partition 1 --type ext4 --name wsaat/mnt/wsl/wsa. Soong and Ninja then run on real Linuxext4, with no 9P in between.wsl --unmount, the disk comes back online in Windows,ext4.sysbringsF:\back, IIS recycles its app pool, and five seconds later the release is up for local tests.flowchart LR A["Windows 11 26H2<br/>ext4.sys -> F:\"] -->|"build_on_f.ps1<br/>disk offline + wsl --mount"| B["WSL2 Ubuntu 26.04<br/>/mnt/wsl/wsa native ext4"] B -->|"Soong + Kati + Ninja<br/>+ zstd -19 --long=31"| C["Packed .zst images<br/>+ manifest.json"] C -->|"wsl --unmount<br/>disk online -> ext4.sys"| D["F:\ on Windows<br/>IIS + Certum SimplySign"] D -->|"5G upload"| E["GitHub Releases<br/>+ kvc.pl mirror sync"]3. Lunar Lake, 32 GB RAM and a memory guardian
The laptop has an Intel Core Ultra 7 258V: 8 cores and 32 GB of on-package RAM. Fast and cool, but the RAM is soldered and that's it, while Windows 11 26H2, WSL2 building AOSP, often WSA itself, debuggers and tools all share it.
OOM kills at the start
At first, building Android 15 on 32 GB didn't work.
soong bootstrapalone peaks at 15.27 GB RSS (maxrss = 15270 MB), and the Linux page cache held on to the whole WSL2 allocation until the OOM killer took the build down halfway or Windows choked.Instead of buying a 128 GB workstation: split the memory and add a watchdog.
During every build a small memory guardian,
dropcache2.sh, runs in the background, only whilesoong_uiorninjais alive:Tip
Every 60 seconds the kernel drops clean file cache and compacts memory pages. WSL2's free page reporting hands the freed pages back to Windows right away, instead of sitting on 16 GB of stale buffers for 40 minutes. Since then: no OOM kills, and the laptop stays usable during builds.
4. A split pipeline instead of 5-hour rebuilds
At the start any non-trivial change meant hours of waiting. Over time the pipeline got split, so the heavy stages run only when needed:
WSA-Next.exe, MSI) and the host graphics stack (ANGLE,Vulkan-Loader,Mesa Dozen) are separate from AOSP. A C++ change on Windows compiles in seconds, a single graphics DLL rebuilds in 1 to 2 minutes and gets tested live without touching the Android disks.-Repackinstead of a full build: when only the Linux6.18kernel or the host graphics DLLs change, AOSP doesn't run at all. The packager puts the signed DLLs into the Windows package, checks the checksums and repacks only the changed component in about 40 seconds..sourcesand.vendorcaches:package-release.shtracks source digests and skips recompressing unchanged images withzstd -19. The cleanedvendor.vhdxhas its own cache, because VHDX conversion writes random GUIDs and would otherwise make every user download the same 16 MB again with every release.5. Soong, Kati, Ninja and the price of a second architecture (
arm64)When Android 15 itself has to be rebuilt, this is what it costs:
soong bootstrapAndroid.bpfiles and recomputes the full AOSP dependency graphckatiAndroid.mkfiles into Ninja rulescombined-*.ninjaninja -j8secilcanddeapexer, buildssystem/system_ext/productand converts to.vhdxzstdpackagingzstd -19 --long=31 -T4using a 2 GB window.sourcesWhat Ninja's dependency graph buys
A cold Android 15 build from scratch takes 4 to 6 hours. Ninja tracks the exact dependencies of every header, object and partition, so changing one service or SELinux policy rebuilds only what depends on it and repackages the
.vhdxdisks. That brings an incremental run down to 25 to 43 minutes.A second architecture doubles the cycle
While there was only
x86_64, Soong's graph inout/stayed warm. Adding Windows on ARM (wsa_arm64_gapps) roughly doubled every full release cycle:11:49to12:32(43 min), then right after, on the same USB disk, ARM64 from12:42to13:07(25 min).6.18kernel forarm64, separate builds and MSIs for x64, ARM64 and the Windows 10 fork, and cross-compiling the whole Windows ARM64 host graphics stack: ANGLE M154, Khronos Vulkan-Loader, Mesa 26.3.1 Dozen.6. Signing, automation and uploading over 5G
A finished build is still only halfway to Publish:
WSA-Next.exerefuses unsigned releases, and the background host turns on Bluetooth and Windows Hello only when the installed Android disks match the signedmanifest.cat. Every.exeand.msi, the four own host graphics DLLs for x64 and ARM64, and bothmanifest.catcatalogs get SHA-256 Authenticode signatures with RFC 3161 timestamps fromtime.certum.pl. The signing key sits behind SimplySign with an OTP from my phone, so this step can't go to a cloud runner..zstcomponents and MSIs, andmanifest.jsonandmanifest.catlast, so nobody gets a manifest that points at old files.kvc.plmirror syncs server-to-server and the pages and checksums get updated.7. A month of reverse engineering: where the time goes
All of the above is just the packaging line. Most of the work happens before
build_on_f.ps1even starts, because WSA-Next joins five layers, with closed Microsoft binaries in the middle:Important
Windows 11 26H2 -> closed Microsoft
WsaClient.exe,WsaService.exeandgfxstream_backend.dll-> custom ANGLE + Vulkan-Loader + Mesa Dozen -> Linux 6.18 kernel on Hyper-V -> Android 15 AOSP + Google Play + apps.A few examples from the last month, the kind of thing that eats evenings and nights before a build even starts:
gfxstream_backend.dll, separately for x64 and ARM64: going from GLES 3.0 to 3.1, lifting the Vulkan memory heap cap and turning on YCbCr emulation without the source ofgfxstream_backend.dllmeant finding the exact call sites in memory, writing runtime patches that check the byte pattern first (on ARM64 with a 16-byte AArch64 trampoline), and addingIDXGIKeyedMutex::ReleaseSyncsynchronization between ANGLE on Vulkan and the D3D11 compositor.vendor.vhdxships 32-bit services, audio among them, and that AOSP builtmediaserveranddrmserver32-bit. So: build AOSP's 64-bitandroid.hardware.audio.serviceagainst Android 13 VNDK 33 symbols only, swap it intovendor.vhdxwithdebugfskeeping permissions andsecurity.selinuxlabels, and switch the whole ARM64 image to pure 64-bitcore_64_bit_only.mk, with zero 32-bit ELFs left.0x57534254), Windows Hello (AIDL V4 fingerprint HAL onUserConsentVerifier),elevatefor package management and for cleaning up what uninstalled apps leave behind (Uninstalled apps have not been removed from either the WSA app list or the Start menu. #40). And today's fix: WSA-Next talks to the localadbserver on port5037withhost:disconnect, so anadb.exeleft running no longer starts WSA again seconds after Stop.D3D12Core.dll+0x2dc0b: it started as a bare0xc0000005insideCreateRenderTargetView. Minidumps incdb.exe, temporary call tracing in ANGLE and Dozen read withdbgviewcli64, and the D3D12 validation layerd3d12SDKLayers.dllshowed a bug in two stages: while emulating ETC2/ASTC compressed textures,gfxstreambound a secondUINTimage into the oversized dedicated memory of anRGBA8image, the GPU device got removed (DXGI_ERROR_DEVICE_REMOVED/DXGI_ERROR_INVALID_CALL), and then missing error handling for descriptor allocation in Mesa Dozen crashed the wholeWsaClient.exe. One fix at the root, indzn_device.canddzn_cmd_buffer.c, meant two rebuiltvulkan_dzn.dllfiles (x64 and ARM64), updated overlays, tests on two machines and two full AOSP runs.logman -pfsilently dropped TraceLogging provider names that aren't registered and gave testers empty 8 KB files, so the raw provider GUIDs ofLatte.Client,WsaServiceandWslCorehad to be pulled out of the WSA 2407 binaries.Wrapping up
So when a release changelog has three short bullet points, under them sits all of this: crash dumps and tracing across four layers, Mesa and ANGLE patches, two AOSP architectures built one after the other on one USB drive through my own
ext4.sys, a memory guardian keeping 16 GB of RAM in check, OTP signing and almost 2 GB pushed over 5G.Not a complaint: the project is fun and moves faster than I expected. It's just a look inside, and the reason updates come in batches instead of every fifteen minutes. Questions about any part of the stack, from
ext4.sys, AOSP on WSL2 and the memory guardian togfxstreamand Mesa Dozen, are welcome in this thread.All reactions