Implement GPUQueue write methods and update wgpu-core
<!-- Please describe your changes on the following line: -->
Implements `GPUQueue.writeBuffer` and `GPUQueue.writeTexture`.
r?@kvark
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Return Option for Window's layout channel
<!-- Please describe your changes on the following line: -->
`Window::layout_chan()` now returns an `Option<Sender<Msg>>`, returning `None` if the window is dead.
FIX#26969FIX#26429FIX#21208FIX#19092FIX#22559FIX#22584FIX#22652
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix#23053
<!-- Either: -->
- [x] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This is my first contribution, I'm trying to figure things out!
This fix passes the test case shown in #23053, however I don't know what the behavior should be in `Document` and `ScriptThread` if `Window::is_alive()` is false : simply ignore it, don't do anything ? Or is this something that should not happen now that we return false in `Window::force_reflow()` ?
I'm not sure about the directory where the test case should go, any advice?
WebGPU update presentation data asynchronously
<!-- Please describe your changes on the following line: -->
This PR aims to make updating Webrender presentation data non-blocking.
A callback is passed to the `buffer_map_async()` fn wherein the data is read and a message sent to the server itself to write the data into the shared `PresentationData` struct object.
r?@kvark
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Update referrer computation
The PR updates the request's referrer computation in consideration with the recent changes in [w3c/webappsec-referrer-policy#135](https://github.com/w3c/webappsec-referrer-policy/pull/135).
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix#27030 and fix#14505
- [x] There are tests for these changes
Implement MediaStreamAudioDestinationNode, MediaStreamAudioSourceNode, MediaStreamTrackAudioSourceNode
Progress in https://github.com/servo/servo/issues/26097
This is a draft since we need the data channels stuff to land first
(also I need to make sure we're passing WPT)
Implement HTMLFormElement.requestSubmit()
<!-- Please describe your changes on the following line: -->
This PR contains an implementation of [HTMLFormElement.requestSubmit()](https://html.spec.whatwg.org/multipage/forms.html#dom-form-requestsubmit)
This is literally my first hundred lines of Rust code, so if I crossed a few sacred lines here and there, please go easy on me :)
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix#23417
<!-- Either: -->
- [x] [WPT tests](https://github.com/servo/servo/blob/master/tests/wpt/web-platform-tests/html/semantics/forms/the-form-element/form-requestsubmit.html) for these changes
There are two tests that still fail because we don't support `:invalid` CSS selector (see #10781). I verified that they pass if you change them to not use `:invalid`. Should be unlocked by #26729.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Ensure clean shutdown of JS threads
<!-- Please describe your changes on the following line: -->
FIX https://github.com/servo/servo/issues/26685
FIX https://github.com/servo/servo/issues/26996
FIX https://github.com/servo/servo/issues/9672FIX#27027
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #___ (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Fix building with --feature js_backtrace
This PR fixes an build error that I ran into when using the `--features js_backtrace` flag.
In particular, the error I ran into was this:
```
error[E0061]: this function takes 2 arguments but 1 argument was supplied
--> components\script\dom\bindings\error.rs:113:45
|
113 | let js_stack = stack.and_then(|s| s.as_string(None));
| ^^^^^^^^^ ---- supplied 1 argument
| |
| expected 2 arguments
```
It seems that the `mozjs` crate updated the [`as_string()` method on `CapturedJSStack`](https://doc.servo.org/mozjs/rust/struct.CapturedJSStack.html#method.as_string) to take two parameters. I've chosen to use `StackFormat::Default` because that will presumably preserve the original intended behavior.
I additionally had to make the block wrapping the feature unsafe as I ran into a "must be marked as unsafe to call unsafe code" build error after fixing the above issue. Seems that this commit (0703a1ad6d) forgot that part.
#### Other Notes
After these changes, I was able to build but ran into an access violation error during runtime. When a JS error hit [`throw_dom_exception()`](https://github.com/servo/servo/blob/master/components/script/dom/bindings/error.rs#L109) and the JS stack was pulled, some sort of issue was hit inside mozjs and [`MOZ_NoReturn()`](bdccbdc656/mozjs/mfbt/Assertions.h (L235)) was called, which will obviously cause an issue.
It is worth noting that this only happened on my test platform (Hololens 2) and not on MacOS or in the Hololens 2 emulator. Additionally, the debug logs were not particularly helpful at identifying the culprit. Maybe it is worth making a full issue for?
Here's the full details:
Error message:
```
Exception thrown at 0x00007FFBCDD16784 (simpleservo.dll) in ServoApp.exe: 0xC0000005: Access violation writing location 0x0000000000000000.
```
Stack Trace:
```
simpleservo.dll!MOZ_NoReturn(int aLine) Line 236
at E:\Projects\Yeti\servo\target\aarch64-uwp-windows-msvc\debug\build\mozjs_sys-aa48eb6c20c205d4\out\build\dist\include\mozilla\Assertions.h(236)
simpleservo.dll!js::SavedStacks::insertFrames(JSContext * cx, JS::MutableHandle<js::SavedFrame *> frame, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 0
at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\vm\SavedStacks.cpp(0)
simpleservo.dll!js::SavedStacks::saveCurrentStack(JSContext * cx, JS::MutableHandle<js::SavedFrame *> frame, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 1292
at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\vm\SavedStacks.cpp(1292)
simpleservo.dll!JS::CaptureCurrentStack(JSContext * cx, JS::MutableHandle<JSObject *> stackp, mozilla::Variant<JS::AllFrames,JS::MaxFrames,JS::FirstSubsumedFrame> && capture) Line 5926
at E:\.cargo\git\checkouts\mozjs-fa11ffc7d4f1cc2d\9a6d8fc\mozjs\js\src\jsapi.cpp(5926)
simpleservo.dll!mozjs::rust::CapturedJSStack::new(mozjs::rust::RootedGuard<mut mozjs_sys::generated::root::JSObject*> cx, core::option::Option<u32> guard) Line 1337
at E:\.cargo\git\checkouts\rust-mozjs-8611526964119dd6\28248e1\src\rust.rs(1337)
simpleservo.dll!script::dom::bindings::error::throw_dom_exception(script::script_runtime::JSContext cx, script::dom::globalscope::GlobalScope * global, script::dom::bindings::error::Error result) Line 114
at E:\Projects\Yeti\servo\components\script\dom\bindings\error.rs(114)
```
Repro:
1. Make a build on Windows for the Hololens 2.
- This is the command I used: `C:\Python27\python.exe mach build -d --uwp --win-arm64 --features js_backtrace`
2. Open the project in Visual Studio.
3. Change the default URL in `DefaultUrl.h` to `"http://yeticgi.casualos.com/?story=test1&pagePortal=home"`.
- Note the lack of HTTPS. There's a separate issue that causes a websocket error. Was trying to debug when I ran into this issue.
- The same issue occurs if you load from a build of this [this repository](https://github.com/casual-simulation/casualos). Follow the instructions in [`DEVELOPERS.md`](https://github.com/casual-simulation/casualos/blob/develop/DEVELOPERS.md) if you do.
2. Run on the [Hololens 2 via Visual Studio](https://docs.microsoft.com/en-us/windows/mixed-reality/using-visual-studio#deploying-an-app-over-wi-fi---hololens-2).
- If the default URL doesn't take effect, you may have to uninstall the app from the Hololens 2 and reinstall.
3. Wait for it to load and stop at a breakpoint for `SavedStacks.cpp`.
- It will say the source cannot be found but its actually because the breakpoint doesn't have a related line in the source code.
- If you continue then it will run into the access violation exception.
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because they fix a build error.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
- mozjs::jsapi::CapturedJSStack::as_string() (https://doc.servo.org/mozjs/rust/struct.CapturedJSStack.html#method.as_string) was updated to accept a second parameter which specifies which Stacktrace format to use. The default has been specified to preserve the (presumably) original behavior.
- The related code has also been placed in an unsafe block since the capture_stack macro calling the unsafe mozjs::jsapi::CapturedJSStack::new() function. Seems that this commit (0703a1ad6d) forgot this part.