-
Notifications
You must be signed in to change notification settings - Fork 123
Description
Description
During code analysis, we noticed that when LocationActivity.onResume() is invoked, the application may experience noticeable UI jank or temporary freezing under certain conditions.
The issue appears to be caused by a synchronous call to LocationView.setLayerType() on the main (UI) thread.
When a data-intensive layer (e.g., NEXRAD) is selected, this method may perform blocking file I/O and bitmap/data parsing, delaying UI rendering until the operation completes.
It may increase the risk of ANR in extreme cases.
Root Cause Analysis
-
LocationActivity.onResume()directly invokesLocationView.setLayerType(...) -
setLayerType()triggers layer-specificparse()logic -
The parsing process (e.g., in
BitmapHolderconstructors) involves:- synchronous file I/O
- bitmap decoding and memory allocation
-
These operations run on the UI thread, blocking rendering and user interaction
Suggested Improvement
It is recommended to move the time-consuming operations inside setLayerType() (file I/O, data parsing, bitmap decoding) off the UI thread and execute them asynchronously.
One possible approach:
- Trigger a background task when resuming the activity or when the user changes the layer
(e.g., using Kotlin coroutines, RxJava, or anExecutor) - Perform file reading and data/bitmap parsing in the background
- Switch back to the UI thread after completion to update the view with the prepared data
This change would improve UI responsiveness and reduce the risk of jank or ANR during lifecycle transitions.