Prerequisites
- A failing or marginal row in the physical-device qualification matrix
- A reproducible package, camera configuration, and session duration
- Release-build measurements for frame rate, memory, and thermal state
Reduce the input workload
Start at 720p and 30 FPS. Increase resolution only when the target device matrix proves the higher setting remains stable. Avoid a second camera controller, per-frame image conversion, synchronous readback, and unnecessary preview duplication.
Reduce active processing
- Keep one authored package active in each intended slot.
- Disable background segmentation when no background feature is visible.
- Remove beauty or makeup controls that are set to their neutral value.
- Avoid starting processed-frame sampling unless the app consumes it.
- Prefer one optimized package over chaining several packages with equivalent output.
The native runtime can selectively skip inference work and adjust recording workload on measured lower-tier Android devices. Host code should still avoid adding its own unbounded queues.
Use latest-frame backpressure
When a consumer cannot keep up, replace pending work with the newest frame. Never accumulate camera frames to preserve every callback; that increases latency and memory until the user sees an old preview.
Verify the optimized experience
Repeat preview, recording, streaming, background/foreground, camera switching, and navigation loops. An optimization is acceptable only when it preserves the required effect output and does not create lifecycle or media regressions.
Common errors
| Symptom | Cause | Fix |
|---|---|---|
| FPS improves but touch or controls lag | Work moved to the UI thread | Keep camera and package mutations serialized without blocking UI work |
| Latency grows during streaming | The host queues every processed frame | Use latest-frame backpressure and release native texture slots promptly |
| Memory rises after every screen visit | Preview, listener, or provider cleanup is incomplete | Stop media work, remove listeners, release the camera owner, then clean up |