-
Notifications
You must be signed in to change notification settings - Fork 143
Open
Description
Hello, I found that _onDraw() inside BRouterMapView performs a large amount of heavy work directly on the UI thread, including:
● Calling Thread.sleep() inside UI rendering (200–500ms)
● Creating a large Bitmap every frame
● Filling large pixel arrays
● Iterating over large sets (openSet, nogoList, wpList)
● Running business logic inside onDraw
● Triggering invalidate() every frame → infinite redraw loop
These behaviors may cause:
- Long UI thread blocking
- Extremely low frame rate
- Frozen UI / unresponsive touch events
- High CPU load
- Potential ANR on many devices
According to Android guidelines, onDraw() must stay lightweight and should not contain:
- Sleeping
- Heavy CPU operations
- Bitmap allocation
- Business logic
- Infinite redraw loops
Suggestions:
- Move all routing calculations and pixel generation to a background thread
- Keep
onDraw()strictly for drawing only - Pass results from worker threads to the View
- Only draw already-prepared bitmap on UI to avoid blocking
This is a structural issue, and fixing it would significantly improve UI responsiveness and stability.
Thank you.
Metadata
Metadata
Assignees
Labels
No labels