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
SVG targeted loader to fix Firefox issues #15013
base: main
Are you sure you want to change the base?
Conversation
📦 Preview the website for this branch here: https://deploy-preview-15013--ol-site.netlify.app/. |
Apart from the expected quality improvement in one test (removal of duplicated row) were no tests or examples which this change might have broken. Image WMS (or ArcGISRest) reprojection with pixelRatio > 1, with or without hidpi setting, if examples existed, might have been have been affected if this change was incorrect, but both appear to be working correctly: https://jsbin.com/ralejivoro/edit?html,output https://jsbin.com/rudegukuli/edit?html,output as do their SVG format equivalents. |
I have found a issue with some SVG on Firefox. This https://jsbin.com/nadaquhodu/edit?html,output displays as expected in Chrome, but not Firefox (where it is also very slow), so suppressing the use of Also when these SVGs are used as icons two dimensional scaling does not work. This can be fixed in #14933 (it is also needed for non-reprojected SVGs whose extent does not match the aspect ratio) but reprojection performance remains unacceptably slow in Firefox unless a raster image is used. |
This is a puzzling example to me. It says "there is minimal blurring (or pixelation if interpolation is disabled) when zooming in." Should I notice any difference when clicking on the "Interpolate" checkbox? I don't notice any difference when recording the animation above. The text says "minimal blurring ... when zooming in." Does this mean blurring during a zoom transition (like "while" zooming in) or blurring at a high zoom level (like "when" zoomed in)? Is the change you are making only relevant when using the |
Some blurring or pixelation (depending on the interpolate setting) is noticeable when zooming. It will only be noticeable when zoomed if you are using a inappropriate pixel ratio for your device (or you are using Firefox, when the fallback will be very noticeable). |
I’ll try to rephrase my question. What is the purpose of the checkbox? |
It does not have much purpose, interpolation could be left either on or off. I think pixelation with interpolation off is more noticeable than interpolated blurring in this example if making a comparison between the two examples. |
src/ol/reproj.js
Outdated
|
||
const stitchScale = pixelRatio / sourceResolution; | ||
let stitchContext; | ||
if (sourceResolution !== 0 || sources.length !== 1 || gutter !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instad of introducing a special meaning of 0
, wouldn't it be more a more general solution to compare sourceResolution
and targetResolution
, and enter this code path when they are equal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Equal or not we always want to do it for Image reprojection (unless Firefox because it is too slow), and do not want to do it for Tile reprojection (we could if there was only one source tile, but the quality would change as soon as a second tile comes into view). Using zero avoids passing another parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the rationale behind it, I'm just not a fan of misusing existing properties with special values to trigger entering different code paths. A clean solution would be to use the same sourceResolution and targetResolution, and add a new boolean property stitch
or something.
I think this pull request could be improved with a rendering test that demonstrated what it does. I'm not sure that the example is necessary. |
Test added. If run in Firefox it would fail because (a) we are using a rasterized fallback and (b) even without the fallback Firefox would not scale that image correctly (unless as in #14933 we use an SVG specific loader to inject The example is similar to having both |
c248b99
to
a7c3b7e
Compare
The test should now work on all browsers, with a simple canvas fallback loader which does not need CORS or rely on user agent. Rebased to include #15039 without which the example would produce large amounts of canvas for garbage collection in Firefox. |
I would be interested in seeing this merged as it will fix #15144. Is there anything I could do to help? |
e8468f3
to
6d2c335
Compare
65db139
to
4cbbfa7
Compare
I have rearranged the commits slightly so the first commit alone will fix #15144 in any browser. As a result the example in the second commit will not use a Firefox fallback and requires the third commit otherwise it might freeze if run in Firefox. |
4cbbfa7
to
fc7ec9d
Compare
Fixes the poor quality SVG reprojection noted in #14945 (comment)
With a single source (either Image or Tile without gutter) reprojection does not need to use a
stitchContext
, the image could be drawn directly to the output context. However for tiles that could result in changes to quality if second tile comes into view, so it is suppressed by only doing so ifsourceResolution
is passed as zero (as it is only needed to create thestitchContext
).ReprojImage
passes 0 unconditionally as even for a bitmap a single scaled draw should produce slightly better results than stretching into astitchContext
followed by further scaling.Added example https://deploy-preview-15013--ol-site.netlify.app/en/latest/examples/reprojection-image-svg.html