Skip to content
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

use switch statement for text snapping decision #3540

Closed
wants to merge 2 commits into from

Conversation

@srijs
Copy link
Contributor

srijs commented Feb 4, 2019

Fixes #3538.

@lsalzman this implements your suggestion of switching from an if to a switch statement, and it really fixes the issue for some puzzling reason! I'd love to put a better description of the issue into the commit message, but this behaviour thoroughly confuses me. Can you offer more insight into why this particular change alleviates the problem?


This change is Reviewable

@nical
Copy link
Collaborator

nical commented Feb 4, 2019

Looks like this should be documented in the driver issues wiki page.

@srijs
Copy link
Contributor Author

srijs commented Feb 4, 2019

@staktrace
Copy link
Contributor

staktrace commented Feb 4, 2019

Thanks for the patch! https://bugzilla.mozilla.org/show_bug.cgi?id=1525032 will merge this to m-c and then it will get synced back to webrender.

@nical
Copy link
Collaborator

nical commented Feb 5, 2019

It sounds very similar to https://github.com/servo/webrender/wiki/Driver-issues#2864---mac-glsl-compiler-bug-with-integer-comparisons, though not quite the same?

Looks very similar indeed, I added https://github.com/servo/webrender/wiki/Driver-issues#2864---mac-glsl-compiler-bug-with-integer-comparisons right next to it, not sure whether they are the same but it's good to keep a history of each workaround.

@kvark
Copy link
Member

kvark commented Feb 5, 2019

What's bothering me here is that local_transform isn't always initialized. Maybe we are just hitting the UB in the shader because of that, and turning if into switch just affects what garbage turns out to be placed on local_transform space, thus luckily improving the results?

@lsalzman
Copy link
Contributor

lsalzman commented Feb 5, 2019

local_transform is only ever used with WR_FEATURE_GLYPH_TRANSFORM, which is only ever used with RasterSpace::Screen

@kvark
Copy link
Member

kvark commented Feb 5, 2019

@lsalzman so you are saying that raster_space has to be SCREEN if the WR_FEATURE_GLYPH_TRANSFORM is enabled? It's unfortunate to leave the shader behave UB when this condition isn't fulfilled by the Rust side for some reason.

@srijs
Copy link
Contributor Author

srijs commented Feb 5, 2019

FWIW, initializing local_transform to the identity matrix on line 74 also fixes the issue on my machine. Happy to push that change instead if you want to go that way.

@lsalzman
Copy link
Contributor

lsalzman commented Feb 5, 2019

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 5, 2019
@kvark
Copy link
Member

kvark commented Feb 5, 2019

@lsalzman are you 100% sure that local_transform wasn't used in this case?
@srijs would you mind setting it to something crazy and seeing if it affects anything?

I'm not a fan of switch fix because that's something we can't explain. And the hypothesis that local_transform is used would provide a much cleaner explanation to the root of the problem :)

@lsalzman
Copy link
Contributor

lsalzman commented Feb 5, 2019

Since this is technically an enum value, the switch is a more natural expression of the intent of the code anyway, so there is no harm in just leaving the switch.

@srijs
Copy link
Contributor Author

srijs commented Feb 5, 2019

I've pushed the additional commit onto the branch.

@kvark using a bogus initializer for local_transform does not have any effect in my case, but given that I only use screen raster spaces, I wouldn't expect to hit the branch where local_transform is used uninitialized?

@lsalzman
Copy link
Contributor

lsalzman commented Feb 5, 2019

WR_FEATURE_GLYPH_TRANSFORM will only get triggered if there is a font transform, which can only happen in RasterSpace::Screen. If RasterSpace::Local is used, then the font transform is identity, and WR_FEATURE_GLYPH_TRANSFORM will never be used. So the only possible way for the shader enum to not actually be RASTER_SCREEN is if there was either a driver bug with the uniform value, or a bug in our uniform code. However, given that this problem only manifests on one very limited configuration on macOS and only on specific hardware, and nowhere else, I think this is just a driver bug.

bors-servo added a commit that referenced this pull request Feb 5, 2019
Sync changes from mozilla-central

Fixes #3540
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Feb 6, 2019
@staktrace
Copy link
Contributor

staktrace commented Feb 6, 2019

Sorry about closing the PR while discussion is still ongoing but the syncing process assumes that once the PR is approved it won't be modified. If the additional commit needs landing please open a new PR with that patch. Thanks!

@srijs srijs deleted the srijs:fix/use-switch-for-text-snapping branch Feb 11, 2019
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
[wrupdater] From servo/webrender#3540

Differential Revision: https://phabricator.services.mozilla.com/D18565

UltraBlame original commit: af2acbe820daaa9ac1b34350bed84d90b1242cf9
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
[wrupdater] From servo/webrender#3540

Differential Revision: https://phabricator.services.mozilla.com/D18565

UltraBlame original commit: af2acbe820daaa9ac1b34350bed84d90b1242cf9
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 4, 2019
[wrupdater] From servo/webrender#3540

Differential Revision: https://phabricator.services.mozilla.com/D18565

UltraBlame original commit: af2acbe820daaa9ac1b34350bed84d90b1242cf9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.