fix(whiteboard): defer invalidate to vsync to avoid flicker#21043
fix(whiteboard): defer invalidate to vsync to avoid flicker#21043hdream0322 wants to merge 1 commit into
Conversation
|
First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible. |
|
sorry, my mistake |
There was a problem hiding this comment.
TL;DR: Let's use git bisectfirst
Thanks for the PR!
This implementation causes a performance regression. Given we know this was introduced between 2.23 and 2.24, we should understand the bug before fixing it, so we can fix it in an effective manner
Given you can reproduce this on your phone, and I can't, please perform git bisect to find the commit which introduced this issue. From there, we can put in a targeted fix.
If you need anything, please let me know
- See: #19364 (comment)
d7b2dab to
edf1dbb
Compare
|
Dug into this some more. The invalidate() calls in handleDrawEvent have been there since 2021, so it's not really a regression — and on my phone every older release flickers too, so I couldn't bisect locally. But @ZornHadNoChoice confirmed 2.23.3 OK / 2.24.0 NG on Xiaomi, so there's clearly some environment trigger I just can't repro here. Ran a bunch of layer-type combos on upstream/main to pin down the mechanism:
That last one pretty much confirmed it for me — the trigger is the synchronous invalidate() on the touch path racing with WebView surface composition. So instead of going back to the SW-layer workaround I switched the stroke hot path to postInvalidateOnAnimation() — same effect, vsync-coalesced, no layer type changes, no perf hit. Would really appreciate it if someone on the affected side (Xiaomi folks especially) could confirm this fixes it for them too. Since this is my first PR, there may be some rough edges or things I've missed. I'd really appreciate it if you could point them out — any feedback would be very helpful. Thank you so much for taking the time to review. |
Purpose / Description
fix card flikering issue while using whiteboard (legacy study screen)
Fixes
(same issue occurs from recent version to 2.21, so I think it's webview issue)
Approach
Force the Whiteboard view to a software layer so its invalidate calls don't disrupt the Webview's GPU.
Webview still on hardware.
How Has This Been Tested?
Tested on Samsung Galaxy TabS9+, Android 13 (SDK 33), WebView 148.0.7778.120.
Steps to reproduce:
Before: card content flashes white during short strokes.
After: no flicker. (Long strokes, single dots, eraser....)
Screen_Recording_20260514_144014_AnkiDroid.mp4
Checklist
Please, go through these checks before submitting the PR.