Handle scale factor change on web-sys backend#1690
Handle scale factor change on web-sys backend#1690ryanisaacg merged 6 commits intorust-windowing:masterfrom
Conversation
ryanisaacg
left a comment
There was a problem hiding this comment.
Nice work, just a couple things before we're good to go 👍
b632fc6 to
d961343
Compare
d961343 to
769d086
Compare
| } | ||
|
|
||
| fn handler(&mut self, event: MediaQueryListEvent) { | ||
| assert_eq!(event.matches(), false); |
There was a problem hiding this comment.
hey @alvinhochun, can I ask what the reason was for this assertion? We are hitting it a lot on a random basis when re-scaling the browser window, but it's erratic and only happens to a few people. We haven't figured out the root cause yet 😬
Is this something that could be changed by a debug assert instead? 🤔
There was a problem hiding this comment.
Hmm, looking back now I don't really see why this assert would fail, but removing this assert should be perfectly fine because it is recoverable. If you think this is appropriate you may change it to just print a debug message somewhere on debug builds.
There was a problem hiding this comment.
Got it! In that case, I'm going to dig a bit more and maybe open a PR for that. 🙂 Thanks for the quick response!
What do you think that message should look like? I still don't quite get what this matches call to the media query is doing.
I know it relates to this https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryListEvent/matches but I don't see why does it matter here whether .matches() return true or false, or why it should always return false in this case.
cargo fmthas been run on this branchcargo docbuilds successfullyCHANGELOG.mdif knowledge of this change could be valuable to usersThis implements scale factor change detection for the web target by using
MediaQueryList. I've only implemented this for theweb-sysbackend. It's currently stubbed out in thestdwebbackend.This PR also includes a small refactor and fixes an issue with the handling of
ControlFlow::Exit(see also #1688).Tested on Firefox and Chrome (Windows) And Firefox (Linux).