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
Loading
Please register or sign in to comment