Google Sheets misrendering due to incorrect built-in WebGL shaders in Firefox
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox-esr102 | --- | unaffected |
| firefox-esr115 | --- | fixed |
| firefox117 | --- | wontfix |
| firefox118 | --- | fixed |
| firefox119 | --- | fixed |
People
(Reporter: lina, Assigned: lsalzman)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 1 obsolete file)
|
1.18 KB,
patch
|
Details | Diff | Splinter Review | |
|
48 bytes,
text/x-phabricator-request
|
pascalc
:
approval-mozilla-beta+
RyanVM
:
approval-mozilla-esr115+
|
Details | Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
Steps to reproduce:
- Open Google Sheets demo on Firefox on a Mac running Asahi Linux
- Scroll around
Example URL: https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0
Actual results:
Canvas contents immediately become blurry as they scroll. This happens because Firefox is using incorrect shader precision specifiers in its built-in shaders.
See DrawTargetWebgl::SharedContext::CreateShaders in dom/canvas/DrawTargetWebgl.cpp. The fragment shaders specify precision mediump float; and then don't use overriding precision qualifiers anywhere. This causes the texcoords to use fp16 precision on GPUs that support it, which is not sufficient for correct rendering.
Expected results:
Normal rendering.
The attached patch should fix the problem (I didn't test it in Firefox, but I made the equivalent change using Mesa's shader replacement feature).
Note that this is a common mistake and the Mesa GPU driver we've been developing actually includes a heuristic that fixes the first instance of the problem (where the varying is used as a texcoord directly), but not the second one where there is an intermediate clamp(). It is that second one that is breaking Google Sheets.
This might need a check for GL_FRAGMENT_PRECISION_HIGH to make sure it doesn't break on very old GPUs without support for that.
| Reporter | ||
Comment 1•2 years ago
|
||
Typo in the first hunk, I had highp varying instead of varying highp. This one should be correct.
| Reporter | ||
Comment 2•2 years ago
|
||
Also for reference, this is what the shaders look like once they get passed to Mesa (they go through some kind of optimization pass in Firefox): https://gist.github.com/asahilina/f0f81e0043894f0737d7f599d205dfc8
Comment 3•2 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Graphics: CanvasWebGL' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 4•2 years ago
|
||
The severity field is not set for this bug.
:jgilbert, could you have a look please?
For more information, please visit BugBot documentation.
Would love to see this triaged and merged, running FF without hardware acceleration in order to use Google Sheets currently which isn't ideal.
Comment 6•2 years ago
|
||
I feel like we need to more carefully audit the use of mediump qualifiers, they're ignored by ANGLE so this is an invisible issue on Windows but can be very problematic on all other platforms. In my experience the only appropriate place to use mediump is on colors.
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 7•2 years ago
|
||
This issue was originally reported by Asahi Lina, and they also proposed the original
version of these changes. I have reworked them a bit just to clean up how clip TCs
are passed down so that distance AA does not have to be highp.
Their original comment describing the issue were, in part:
"See DrawTargetWebgl::SharedContext::CreateShaders in dom/canvas/DrawTargetWebgl.cpp. The fragment shaders specify precision mediump float; and then don't use overriding precision qualifiers anywhere. This causes the texcoords to use fp16 precision on GPUs that support it, which is not sufficient for correct rendering."
"Note that this is a common mistake and the Mesa GPU driver we've been developing actually includes a heuristic that fixes the first instance of the problem (where the varying is used as a texcoord directly), but not the second one where there is an intermediate clamp(). It is that second one that is breaking Google Sheets."
Updated•2 years ago
|
Comment 9•2 years ago
|
||
| bugherder | ||
| Assignee | ||
Updated•2 years ago
|
| Assignee | ||
Comment 10•2 years ago
|
||
Lina, can you confirm if the patch I landed successfully resolves the issue for you once it is included in a nightly build?
Updated•2 years ago
|
Comment 11•2 years ago
|
||
Matt, maybe you can confirm that things look better on current Nightly builds?
Comment 12•2 years ago
|
||
Hi Ryan,
I can't replicate this on current Firefox installed for Fedora (like I was able to 9 days ago) so I'm not sure I'd get a good indication on a nightly if this is fixed or not, as I have no 'bad' baseline to compare to. I updated Asahi Linux a few days ago (Tuesday I believe), however there was talk on the forum that Asahi would integrate a fix their end to workaround this https://discussion.fedoraproject.org/t/really-blurry-fonts-in-google-sheets-in-ff-after-scroll/89281 - I guess this got deployed in the meantime. Note: I'm not using ASAHI_MESA_DEBUG=no16.
I'll play some more and if I can replicate it, I'll then test nightly
| Reporter | ||
Comment 13•2 years ago
|
||
Are there ARM64 nightlies? Last I checked it was only x86-64 on Linux...
We actually disable float16 for all browsers now anyway, to work around bad WebGL apps, so if you use the latest driver/config build it should work either way. You have to edit the driconf (/usr/share/drirc.d/00-mesa-defaults.conf) to comment out the workaround to properly test it.
| Reporter | ||
Comment 14•2 years ago
|
||
I just got a report via Twitter that the bug is fixed in self-compiled 119.0a1 🎉
Comment 15•2 years ago
|
||
Now that this has gotten some verification in the wild, is this ready for a Beta approval request?
| Assignee | ||
Comment 16•2 years ago
|
||
Comment on attachment 9352060 [details]
Bug 1845309 - Use highp for texcoords in DrawTargetWebgl shaders. r?jrmuizel
Beta/Release Uplift Approval Request
- User impact if declined: Potential Canvaas2D drawing artifacts on mobile GPUs.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: Yes
- Needs manual test from QE?: No
- If yes, steps to reproduce:
- List of other uplifts needed: None
- Risk to taking this patch: Low
- Why is the change risky/not risky? (and alternatives if risky): Verified. Shouldn't overtly change the way anything is rendered, but just fixes a potential bug.
- String changes made/needed:
- Is Android affected?: Yes
Comment 17•2 years ago
|
||
Comment on attachment 9352060 [details]
Bug 1845309 - Use highp for texcoords in DrawTargetWebgl shaders. r?jrmuizel
Approved for landing on mozilla-beta before the merge, will be in the 118.0 release candidate, thanks.
Comment 18•2 years ago
|
||
| uplift | ||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 19•2 years ago
|
||
Comment on attachment 9352060 [details]
Bug 1845309 - Use highp for texcoords in DrawTargetWebgl shaders. r?jrmuizel
Approved for 115.4esr.
Comment 20•2 years ago
|
||
| uplift | ||
Updated•2 years ago
|
Description
•