From 5a78fe33e84023ca4c89cc30ebeebac0fe89e8f0 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Sat, 10 Oct 2020 06:31:51 +0200 Subject: [PATCH] Fix failing assertion on start-up with Safari (#1736) The initial media query that's used to watch for device pixel ratio changes should match. Unfortunately it doesn't with Safari and the corresponding assertion fails. This is because resolution is not a supported support property for queries. As a workaround, this patch extends the query to optionally match for the webkit specific DPR property directly. This fixes #1734 --- src/platform_impl/web/web_sys/scaling.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform_impl/web/web_sys/scaling.rs b/src/platform_impl/web/web_sys/scaling.rs index 2129a165..08b52ae3 100644 --- a/src/platform_impl/web/web_sys/scaling.rs +++ b/src/platform_impl/web/web_sys/scaling.rs @@ -59,9 +59,9 @@ impl ScaleChangeDetectorInternal { // We add 0.0001 to the lower and upper bounds such that it won't fail // due to floating point precision limitations. let media_query = format!( - "(min-resolution: {:.4}dppx) and (max-resolution: {:.4}dppx)", - current_scale - 0.0001, - current_scale + 0.0001, + "(min-resolution: {min_scale:.4}dppx) and (max-resolution: {max_scale:.4}dppx), + (-webkit-min-device-pixel-ratio: {min_scale:.4}) and (-webkit-max-device-pixel-ratio: {max_scale:.4})", + min_scale = current_scale - 0.0001, max_scale= current_scale + 0.0001, ); let mql = MediaQueryListHandle::new(&media_query, closure); if let Some(mql) = &mql {