Skip to content
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

Implement recreate_context for WebGPU canvas and fix handle_wgpu_msg crash #30386

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sagudev
Copy link
Member

@sagudev sagudev commented Sep 19, 2023

This makes wgpu examples work.

Depends on #30406. DONE

Current state of webgpu examples

Works on reload:

Does not work on reload (but works on freshly opened servo; see #30417):


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes in examples and webgpu-cts

@sagudev sagudev added the A-content/webgpu The WebGPU implementation. label Sep 19, 2023
@mrobinson
Copy link
Member

Maybe I am doing something wrong or we do not have those media query implemented.

If those tests use iframes to trigger media query changes, note that all iframe media query tests are incredibly flaky and brittle because of Servo's loose implementation of iframe loading order.

@sagudev
Copy link
Member Author

sagudev commented Sep 22, 2023

When based on #30406 there is no error on wgpu examples. But when refreshed examples do not work (also non-ui wgpu examples), maybe that's has something to do with wasm loading as pure JS examples work normally on refresh too.

@sagudev

This comment was marked as resolved.

@sagudev sagudev changed the title Impl recreate_context for WebGPU canvas Impl recreate_context for WebGPU canvas and fix handle_wgpu_msg crash Sep 26, 2023
@sagudev sagudev marked this pull request as ready for review September 28, 2023 12:40
@sagudev
Copy link
Member Author

sagudev commented Sep 28, 2023

Resize canvas example from webgpu-samples still crash, but that is not problem with recreate_context.

@sagudev sagudev marked this pull request as draft September 28, 2023 12:49
@sagudev sagudev marked this pull request as ready for review September 28, 2023 15:26
@sagudev
Copy link
Member Author

sagudev commented Sep 28, 2023

components/script/script_thread.rs Show resolved Hide resolved
canvas: HTMLCanvasElementOrOffscreenCanvas,
#[ignore_malloc_size_of = "manual writing is hard"]
/// <https://gpuweb.github.io/gpuweb/#dom-gpucanvascontext-configuration-slot>
config: RefCell<Option<GPUCanvasConfiguration>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the configuration ever read other than to know whether to reconfigure the context? Why not just store a bool?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only for reconfigure AFAIK.

components/script/dom/gpucanvascontext.rs Show resolved Hide resolved
Comment on lines +208 to +210
if let Some(config) = self.config.take() {
self.Configure(&config)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't the call Unconfigure() here instead of in Configure()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's how it was done in mozilla, but I will recheck specs tomorrow.

@mrobinson mrobinson changed the title Impl recreate_context for WebGPU canvas and fix handle_wgpu_msg crash Implement recreate_context for WebGPU canvas and fix handle_wgpu_msg crash Oct 3, 2023
@sagudev sagudev marked this pull request as draft October 3, 2023 14:49
@sagudev sagudev mentioned this pull request Oct 3, 2023
4 tasks
@sagudev
Copy link
Member Author

sagudev commented Oct 3, 2023

I will need to rethink this, so I spitted off crash fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-content/webgpu The WebGPU implementation.
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

None yet

2 participants