Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 56a930e7 authored by Lyn Han's avatar Lyn Han
Browse files

Add timeout to loadImage to prevent shade freeze

Problem: notifications do not show until a few seconds
after the shade opens, caused by a blocking call to load
ic_brightness_full.xml for the brightness slider

Call stack that blocks UI:
- The UI (produceState in BrightnessSlider.kt) waits for the icon
  to load before it can finish drawing.
- The ViewModel's loadImage function calls imageLoader.loadDrawable.
- imageLoader switches to a background thread but then calls a
  synchronous loadDrawableSync that hangs while trying to load the xml.
- Because the background thread is frozen, the UI thread, which is
  waiting for the result, is also frozen.

Solution:
The fix wraps the imageLoader call in a 500ms timeout.
If loading the icon takes too long, we cancel and return null,
so the UI remains responsive and renders notifications promptly
on shade open.

Fixes: 423364554
Test: BrightnessSliderViewModelTest.kt
Test: open shade, notifs show with no delay, brightness slider has no    regressions; screenrecord in bug
Flag: EXEMPT bug fix
Change-Id: I3674060e2925acb326f0b120c09b2663112e7cba
parent 25929b52
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment