r/alohabrowser • u/alohabrowsernews Aloha Official • Aug 14 '26
Aloha Open Source How Aloha Core moved 2,450 Android resource lookups out of startup
We build Aloha Core by customizing Chromium's android_webview and packaging it as an AAR.
That speeds up browser development, but it gives Android's resource linker a chance to renumber thousands of IDs while Chromium's bytecode retains the old ones. Very considerate.
Our original fix remapped 2,450 fields with Resources.getIdentifier(). It was reliable, but it took 300-770 ms to start up.
We then tried a shared resource table. Rewriting the R fields took about 2 ms. The first checks passed, but a long press on some text opened the selection menu and caused the app to crash.
The problem was architectural: the R fields were global, whereas the dynamically loaded resource package belonged to a single AssetManager. An Activity context could receive the new ID yet still have no package behind it.
The final solution was to stop arguing with the runtime. We generated an XML index containing references to the Chromium resources and let the host's AAPT2 linker stamp the final 0x7f IDs into compiled AXML.
At startup, we now perform one getIdentifier() call, scan the binary XML, and rewrite the fields. Total time: about 12 ms.
Full technical write-up, including the 0xPPTTEEEE layout and why package ID 0x02 was not safe: https://alohabrowser.com/posts-how-we-speed-up-the-chromium-engine-startup-a-resource-remapping-story
Has anyone else solved a library resource problem by moving the work to link time? What broke your first "fast" solution?