-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent stale frames from being drawn / always ensure up-to-date contents in webview #3668
Conversation
At key points where external changes enter the webview, stale images might get rendered. This ensures that a frame showing current state is always shown.
Didn't notice a difference or issues testing this, and it looks harmless to include. Will leave it to @dae though. |
I presume the answer is yes, but could you confirm the issue you're trying to address also exists when the software driver is enabled? My understanding of this rendering issue is that for most people, they either won't see the problem, or only see it with particular video drivers. The changes in this PR would thus make things better for a relatively small portion of the userbase, so it would be nice not to impose a performance penalty on unaffected users. You've placed .update() calls in four separate locations. In your testing, were all locations required, or did you add some "just in case"? If you experiment with scheduling an .update() for a few seconds after JavaScript is evaluated, instead of calling .update() immediately, does the corrupt display refresh correctly after those seconds elapse? |
Apologies for the late reply, I am currently preparing for my exams so I am currently slower to respond.
Yes, I have tried basically all driver configurations and run them for prolonged amount of times and they occured all across them, including software. Vulkan is the one where it occurs the least.
It shouldn't have a large penalty since it essentially just causes a second frame to be rendered when the webview is externally interacted with from python code. In essence this makes sure that a frame with the current state is being put to the screen.
I will look into that and verify and share my results here. As I said in the beginning I am currently preparing for my exams so it could take a bit, but maybe someone else can also reproduce the bug. I will also share the deck I am currently using (漢字.apkg.gz). The bug happens regularly on my Surface Pro 9 every about ~10-100 times in the |
Thanks for your patience Luca. I'm inclined to agree with your assessment that this shouldn't cause a large performance impact, and if it's addressing issues that aren't fixed by a video driver switch, it's probably for the best. If you wouldn't mind just briefly trying to remove any superfluous update() calls so we can get this down to the minimum required changes, that'd be appreciated. |
I lost this one during some git troubles.
I have removed the calls in any place except My testing scheme is stochastic to put it in a nice way, but I don't know how else to test such an issue. I can say that this seems to fix the issue for my deck though. Side question: Should I add a comment to the instruction linking to this PR or is the |
The function is supposed to take a boolean telling it whether or not the loading succeeded, which it doesn't as is. However, this is unrelated and works either way so I also reverted it again.
A callback will be used either way for this call, so it can be simplified. The check happens inside the handler.
Thanks for making those changes. Happy to approve this as soon as the conflict is resolved. A one-line comment above the .update() call that explains why we're doing it might be worth adding. |
One can see what is being done, why is probably more important.
Thank you for the reply. I have added a comment referencing this PR and explaining what it prevents. |
Following up on #3656
Short description
At key points where external changes enter the webview, stale images might get rendered. This ensures that a frame showing current state is always shown.
What it solves
Sometimes previous or corrupted frames get rendered, only showing the current state of the page (i.e. the back of the card or the next card) when an action that causes a repaint is done by the user (for example: selecting text).
How it solves it
At key points where the webview is being interacted with externally, a full update (which includes a repaint) is done.
Potential implications for performance
While this ensures that no more stale frames get shown, it also causes full repaints to happen quite often and in addition to the render operations QWebEngineView might do on its own. I think this is negligible in my testing, but needs to be pointed out.
Request for comments
In my testing this solved the issue, and this time it seems to do so reliably, however, please leave feedback or opinions on this. It is also a bit of a wooden-hammer-approach, but it does fix the issue.