DEV Community

hammi
hammi

Posted on

Why my 1.17 MB player opens in under 400 ms cold: zero content providers, lazy init, and a startup window that only draws a color

Everyone talks about download size. Nobody talks about the first 400 ms. My player is 1.17 MB on Android, and on a 2 GB Moto G Play the difference between "opens instantly" and "opens eventually" is entirely in what runs before the first frame.

I profiled cold starts with adb shell am start -W and Macrobenchmark, and the numbers matched what the Android docs say: TTID (time to initial display) is what users feel, TTFD is what they can actually use. A splash screen gets you a good TTID. It does nothing for TTFD. So I optimized both, separately.

What I cut:

  1. Zero ContentProviders. No androidx.startup, nothing auto-initializing. A 1.17 MB APK cannot afford a provider doing disk I/O on the main thread before onCreate finishes. Everything is lazy, pulled on first use.
  2. The startup window only draws a color. windowBackground on the theme, no bitmap, no inflation. First frame lands in tens of ms because there is nothing to inflate.
  3. The video surface is created but not attached until the first file opens. SurfaceView/TextureView creation is not free on old devices, and the home screen does not need it.
  4. All JSON parsing, thumbnail decode and list binding happens after the first frame is drawn, chunked so the main thread never blocks longer than one frame.

The result on the Moto G Play: cold start to first frame is around 250-350 ms, and the home list is interactive under 500 ms. That is the whole trick. There is no library magic in a 1.17 MB binary; there is just refusing to do work before the user sees anything.

I also tried baseline profiles for a while and dropped them. On a binary this small the AOT compilation tax on install was not worth the jank reduction, and Play already does partial AOT on install for API 28+. Startup profiles via dex layout were the bigger win and they cost zero runtime bytes.

Disclosure: I build RKMovies, an ultra-lightweight 4K player client for Android and Windows (1.17 MB APK, 29.5 MB installer, hardware decode, multi-audio, WebVTT subs, no account, zero telemetry). More here: the home page of the thing, the 1.17 mb sideload link, the windows installer page.

Top comments (3)

Collapse
 
alexcodebytes profile image
Oleksandr •

"A splash screen gets you a good TTID. It does nothing for TTFD" is the sentence more Android devs need to read. Most splash screens are just a prettier loading screen — they measure well and help nobody.

The zero ContentProviders decision is the one I'd underline. Half the startup jank on budget devices comes from androidx.startup silently pulling in disk I/O before onCreate even finishes, and nobody notices because it's not in their code.

Collapse
 
hammiwor profile image
hammi •

this landed with me. the part about "A splash screen gets you a good TTID. I is exactly what i keep hitting on budget devices too. nice writeup

Collapse
 
alexcodebytes profile image
Oleksandr •

Exactly. A splash screen is just a band-aid that hides the problem instead of fixing it. Getting a good TTID (Time to Initial Display) with a static color is useless if the actual time-to-interactive is still painfully slow. On budget devices, users see right through the illusion.