-
Notifications
You must be signed in to change notification settings - Fork 953
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
OffscreenCanvas Support for WebGL Backend #2603
OffscreenCanvas Support for WebGL Backend #2603
Conversation
…ion is taken from workspace
af59960
to
b089cd2
Compare
I think this PR is ready for review. Looking forward to improvement ideas! |
@zicklag would you be able to review? |
07067bc
to
1846bec
Compare
The new |
It would definitely be unfortunate to duplicate any examples for WebGL + OffscreenCanvas specifically. If you can make it by just modifying the example (conditionally on the target platform, potentially), that would be great! |
Sure. Does it make sense to add an |
Does it have to be a feature? Can it be just a run-time switch for the skybox example? |
I like the idea, I guess the only question is how to activate it in the wasm environment? Any ideas? Depending on the approach, maybe it's an advantage to provide it for all examples. It has to be implemented in the shared framework.rs anyway. |
I've done runtime flags for WASM before by reading the query string. So you could access the example with Not sure when I'll get to being able to do a review, but I'll try to get to it soon if I have time. |
Cool, I will try that in the next couple of days or on the weekend latest. Maybe this way it could be allowed for all examples. Which is probably nice for testing. |
…?offscreen_canvas=true
@zicklag I was able to make OffscreenCanvas usage configurable in all examples via |
What's the current status of this PR? Any way I can help drive it forward? |
Thanks for running the CI pipeline. I've fixed the Other than that the PR is ready to be reviewed. |
Okay, I was able to check locally at least the Windows and WebAssembly warnings. @cwfitzgerald could you approve again the workflow run for this PR? Would you also review the PR?
|
I just did a quick review and it looks fine to me, but it wasn't a very thorough review, more like a quick sanity check to see if anything sticks out to me. I tested the cube and skybox examples and they work in my browser: I noticed the shadow example is broken for me, but it's like that on master, so not because of this PR. My first thought is that it's probably fine just to use the offscreen canvas example in Good job, this looks neat! |
Thanks a lot for the feedback @zicklag! Do you remember if the |
Yeah it was working back when we first got the WebGL stuff working again, but I think I noticed the demo on the website not working maybe ~3 months ago or more ( I hadn't really kept track ). I wasn't sure if it was my browser or something, but the fancy Bevy PBR & glTF demos still work, so it might be just a problem with the example and not with the backend. Or it's a small backend workaround that needs to be implemented to avoid a problem that only shows up in the example. I'm getting this error every frame:
( But I should probably open a new issue, I just hadn't gotten the chance yet. ) |
Really wish there was an "approve running for this whole pr". I get why but it's exceedingly annoying when you have CI that can't really be hijacked.
Agree with @zicklag here, hello-triangle needn't do everything, it's job is to be simple.
Great, will review in the next couple days |
Is workflow run approval only required for the first-time contribution? If yes, a workaround could probably be a "fake" contribution after the initial PR. |
The remaining build issues are because of the missing functions in the "webgl+emscripten" flavor. Does anyone know how the emscripten version is typically used? Would it be an interesting use case to pass a Canvas or OffscreenCanvas created externally? |
How should web workers fit into this PR (if at all)? Or are we focused on the use case of targeting multiple canvas on the same UI thread for now?
It would probably be useful to expose offscreen canvas support to Emscripten eventually, but for simplicity we could skip it for now. As far as I know, a lot of applications using Emscripten use a default canvas created by Emscripten. |
To me, the main use case is updating multiple canvases with the same OffscreenCanvas as a workaround to share resources between them. But if the changes required for web-worker support would be small, we could consider it as well. Otherwise, a separate PR might be better. @grovesNL Do you have experience with that?
I agree, it's probably better to keep things simple at least until somebody shows interest. |
Yeah, it's just first time. It's not enough of a hassle to bother doing "intro" PRs, but enough that I want to complain about it 😆 |
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.
Looks good, minus some small nits!
0a1e816
to
95ca719
Compare
@cwfitzgerald please also approve the workflow run. If I checked the right things, the builds should pass now. 😉 |
Cool, the build was successful. Let me know if there are more improvement ideas. Otherwise, I'm looking forward to getting this merged 😊 |
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.
LGTM! Thank you!
Connections
Ideas discussed in #1686, Thanks @zicklag for helping me to get started 🙏
Description
The goal is to expose
create_surface_from_canvas()
andcreate_surface_from_offscreen_canvas()
also for the WebGL Backend.Testing
Will be tested in Firefox and Chrome on Windows 10.
The skybox_offscreen example can be used for testing.