-
-
Notifications
You must be signed in to change notification settings - Fork 828
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
web: Deprecate 'canvas' backend #7459
Conversation
We currently have 3 render backends: 'canvas', 'webgl', and 'wgpu'. Assuming that we eventually merge the SVG backend proposed in ruffle-rs#1168, we'll have to maintain 4 independent render backends. I believe that we should be able to drop 'canvas' support, and only rely on 'webgl' (and 'wgpu' in the future) for browser support. This PR doesn't actually remove anything yet - we just display a click-through warning: "Using deprecated canvas backend! Please file a bug report" when the canvas backend is enabled. If it turns out that no one ever hits this warning in practice, we could move to disable the 'canvas' feature in the `web` crate by default. If there are still no bug reports, we could remove the backend entirely. caniuse.com shows the following global availability percentages: 'HTML element: canvas': 97.25% (https://caniuse.com/mdn-html_elements_canvas) 'WebGL (version 1)': 98.02% (https://caniuse.com/webgl) 'Canvas (basic support)': 99.51% (https://caniuse.com/canvas) Based on the data, dropping 'canvas' support would essentially only impact users with WebGL support disabled. It's possible that some browsers might do this for certain websites for privacy/security reasons - however, we already require WebAssembly, so I doubt that WebGL would ever be the only blocker for running Ruffle. The biggest potential downside to this is implementing 'BitmapData.draw'. In order to support SWFs that perform rapid 'BitmapData.draw; BitmapData.getPixel' sequences, we're going to need to perform CPU rendering to avoid blocking on copying data back and forth from the GPU. Using the 'canvas' backend for 'BitmapData.draw' would be one way to accomplish this - however, we would still need a separate backend for the desktop. I believe we could use the SVG backend on all platforms for implementing 'BitmapData.draw'. We'd need to add a dependency on an SVG renderer for desktop, and abstract over `web-sys` vs the `svg` crate. However, I think the result will be a large net reduction in code and maintenance burden.
Honestly I think the canvas backend is still useful. Apart from being helpful for testing stuff, it should be necessary for Ruffle to work on privacy browsers like Tor, which does support WebAssembly. Whether or not such support is important is arguable, though. |
I agree with relrel. There are also issues like #1905 that should be considered first imho because if there's no reliable way to fix these, we may need to fallback to the canvas render. |
I can certainly sympathize with wanting to reduce the # of render backends, but I agree with the above -- the canvas backend has use, so I wouldn't want to deprecate it. There are a few users of it (privacy-aware browsers like Tor and Brave, #1992), and although we don't guarantee support for these, I don't mind trying to support these when it's not too hard. More importantly to me, the canvas backend is a nice reference backend for comparison with our GPU backends. An SVG backend would be good for:
But there are these issues:
I'm definitely okay if someone wants to take a stab at getting the SVG backend up and running on web. It'd also be neat to be able to take SVG screenshots. But it's all relatively low priority in my estimation. Personally, I didn't have plans of working on #1168 at this point. It was more useful when we were using SVG in the canvas backend already, but as I've found workarounds to use pure canvas in these cases, it seems less important. |
Is there any work pending this PR? Sorry @Aaron1011, but I think we should close this without merging. |
Yep, gonna close this one -- we can revisit if an SVG backend is fleshed out. |
We currently have 3 render backends: 'canvas', 'webgl', and 'wgpu'.
Assuming that we eventually merge the SVG backend proposed in #1168,
we'll have to maintain 4 independent render backends.
I believe that we should be able to drop 'canvas' support, and
only rely on 'webgl' (and 'wgpu' in the future) for browser
support.
This PR doesn't actually remove anything yet - we just display
a click-through warning:
"Using deprecated canvas backend! Please file a bug report"
when the canvas backend is enabled.
If it turns out that no one ever hits this warning in practice,
we could move to disable the 'canvas' feature in the
web
crate by default. If there are still no bug reports, we could
remove the backend entirely.
caniuse.com shows the following global availability percentages:
'HTML element: canvas': 97.25% (https://caniuse.com/mdn-html_elements_canvas)
'WebGL (version 1)': 98.02% (https://caniuse.com/webgl)
'Canvas (basic support)': 99.51% (https://caniuse.com/canvas)
Based on the data, dropping 'canvas' support would essentially only
impact users with WebGL support disabled. It's possible that some
browsers might do this for certain websites for privacy/security
reasons - however, we already require WebAssembly, so I doubt
that WebGL would ever be the only blocker for running Ruffle.
The biggest potential downside to this is implementing
'BitmapData.draw'. In order to support SWFs that perform rapid
'BitmapData.draw; BitmapData.getPixel' sequences, we're going
to need to perform CPU rendering to avoid blocking on copying
data back and forth from the GPU. Using the 'canvas' backend
for 'BitmapData.draw' would be one way to accomplish this - however,
we would still need a separate backend for the desktop.
I believe we could use the SVG backend on all platforms for implementing
'BitmapData.draw'. We'd need to add a dependency on an SVG renderer
for desktop, and abstract over
web-sys
vs thesvg
crate. However,I think the result will be a large net reduction in code and maintenance
burden.