aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
Commit message (Collapse)AuthorAgeFilesLines
* fix handle_wgpu_msg crash (#30479)Samson2023-10-031-0/+1
| | | | | | | * Enter realm before handle_wgpu_msg fix https://github.com/servo/servo/issues/30419 * Update expectations
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-92/+88
| | | | | * strict imports formatting * Reformat all imports
* remove `extern crate` (#30311)Samson2023-09-081-1/+2
| | | | | | | | | | | * remove extern crate * Update components/script_plugins/lib.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
* constellation: crash to a new “sad tab” error page (#30290)Delan Azabani2023-09-061-1/+3
| | | | | | | | | | | | | | | | | | | | | * constellation: crash to a new “sad tab” page * check in resources/crash.html * use a separate enum variant instead of keying on reason * fmt + tidy * rename Resource::Crash to Resource::CrashHTML * clean up crash page and add details (reason + backtrace) * avoid repeating crash errors in script::script_thread warn log * make new LoadData init more idiomatic * clarify comments and new fields * fix doc comment style
* Remove unused import `EventLoopWaker` (#30110)Oriol Brufau2023-08-171-1/+1
| | | Seems a remnant from #30101
* Remove `EventLoopWaker` from Constellation (#30101)Atbrakhi2023-08-151-6/+1
| | | | | | | | | | | | | * remove event_loop_waker that is always None * remove None event_loop_waker form InitialScriptState * fix formatting * remove None event_loop_waker from ScriptThread * remove None EventLoopWaker from Window * remove None and use of wake_after_send in webgl code
* Use mozjs tracing infrastructure (#29918)Samson2023-08-101-2/+2
| | | | | | | * Update mozjs https://github.com/servo/mozjs/commit/64711ec2e6dc4595df691bffc7f1e5052ab86c8d also fixes https://github.com/servo/servo/issues/30043 * Move to mozjs Traceable and introduce CustomTraceable
* No tracing of nop traceable fields (#29926)Samson2023-08-041-7/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add `no_trace` option to JSTraceable derive * NoTrace wrapper * Port some types to no_trace schematics * Fixing my unsafe mistakes (not tracing traceables) * Add docs & safety guards for no_trace Safety guards (trait shenanigans) guarantees safety usage of `no_trace` * Port canvas_traits to no_trace * Port servo_media to no_trace * Port net_traits to no_trace * Port style to no_trace * Port webgpu to no_trace * Port script_traits to no_trace * Port canvas_traits, devtools_traits, embedder_traits, profile_traits to no_trace * unrooted_must_root lint in seperate file * Add trace_in_no_trace_lint as script_plugin * Composable types in must_not_have_traceable * Introduced HashMapTracedValues wrapper * `HashMap<NoTrace<K>,V>`->`HashMapTracedValues<K,V>` * Port rest of servo's types to no_trace * Port html5ever, euclid, mime and http to no_trace * Port remaining externals to no_trace * Port webxr and Arc<Mutex<_>> * Fix spelling in notrace doc
* Enter realms when creating special same-origin iframes.Josh Matthews2023-05-201-0/+1
|
* Enter realms when processing pre-sequential events.Josh Matthews2023-05-201-1/+9
|
* Enter realms more consistently during the script event loop.Josh Matthews2023-05-201-3/+21
|
* Make GlobalScope.get_cx a static method.Josh Matthews2023-05-201-2/+2
|
* Auto merge of #29693 - mrobinson:cleanup-options, r=mukilanbors-servo2023-05-031-41/+14
|\ | | | | | | | | | | | | | | | | | | | | | | | | Clean up how command-line options are passed around <!-- Please describe your changes on the following line: --> --- <!-- 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 #29678 - [x] These changes do not require tests because they do not change behavior.
| * Clean up arguments passed to ScriptThreadMartin Robinson2023-05-011-41/+14
| |
* | Fix flakiness in animation testsMartin Robinson2023-05-021-3/+4
|/ | | | | | | | | | | | | | 1. When updating the animation timeline, ensure that nodes that are animating are marked dirty, if necessary, so any style queries will force an layout flush. 2. Disable the problematic transition test suites, as they are in Gecko. These suites often fail when Servo is so overloaded that it cannot deliver frames fast enough to get more than two samples during the animation lifecycle. Fixes #28334. Fixes #26435. Fixes #21486.
* fix(script): request animation ticks if `Animations::pending_events` is not ↵yvt2023-02-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | empty Fixes the test case `/_mozilla/css/css-transition-cancel-event .html`, which was failing under a specific circumstance. The observed sequence of events during the failing test run looks like this: 1. Transitions start in `div1` and `div2`. 2. `div1` generates a `transitionend` event. 3. The `transitionend` event handler removes `div2` from DOM, cancelling its ongoing transition. 4. `div2` is supposed to generate a `transitioncancel` event in a timely manner, which it does not. The test fails as a result. What is going on here? Here's a possible explaination: 1. During one invocation of `ScriptThread::handle_msgs`... 2. In step 2, `ScriptThread::update_animations_send_events` -> `Document ::update_for_new_timeline_value` detects the completion of the transition, and in response, pends the `transitionend` event. 3. In step 3, `ScriptThread::update_animations_send_events` -> `Animations::send_pending_events` calls the `transitionend` handler. 4. The `transitionend` event handler removes `div2`, thereby cancelling its ongoing transition and triggering a reflow. 5. Reflow takes place. During this, `Animations::do_post_reflow_update` -> `Animations::handle_canceled_animations` pends the `transitioncancel` event (precursor to step 4). 6. Having discovering that there was no running animation, `Animations:: do_post_reflow_update` calls `self.update_running_animation_presence (_, false)`, which sends `AnimationState::NoAnimationsPresent`. 7. The invocation of `ScriptThread::handle_msgs` ends, and another starts. It blocks waiting for events. 8. Meanwhile, the compositor receives `AnimationState:: NoAnimationsPresent` and stops further generation of animation ticks. 9. With no events to wake it up, the script thread is stuck waiting despite having the pending `transitioncancel` event (step 4). The HTML specification [says][1] that "an event loop must continually run [...] as long as it exists" and does not say it can block if there is nothing to do. Blocking is merely optimization in a user agent implementation. Pending animation-related events must be processed every time a "rendering opportunity" arises unless the user agent has a reason to believe that it "would have no visible effect". Skipping the processing of animation-related events would have visible effect if such events are indeed present. The correct implementation in Servo, therefore, would be to request more animation ticks so that such events are processed in a subsequent tick. [1]: https://html.spec.whatwg.org/multipage/#event-loop-processing-model
* fix(script): update animation timeline before processing pending eventsyvt2023-02-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit reverses the order of the `send_pending_events` and `update_animation_timeline` calls in `ScriptThread::update_animations_ send_events` so that animation-related events pended by the latter are processed by the former. The new calling order is more compliant with the "update animations and send events" algorithm steps from [the Web Animations specification][1]. The old implementation was prone to blocking for an indefinite period while holding pending events. Due to complex interaction with other events and timing behavior, I was only able to reproduce the problem under the following conditions: - *The `maybe_observe_paint_time` call in `LayoutThread::compute_abs_ pos_and_build_display_list` is removed from the code*. While performance events may seem irrelevant to the issue, they would bombard the script thread with events. *Any* extra messages received would unblock the event loop and prevent the manifestation of the issue. (But, of course, we aren't supposed to count on that to avoid the issue.) - Servo is running in a headless mode, which somehow makes it less likely for the script thread to receive a `TickAllAnimations` event after sending `AnimationState::NoAnimationsPresent`. With the above conditions met and the stars aligned, you can reproduce the problem by running the WPT test `/css/css-transitions/events-001. html`. [1]: https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events
* refactor(script): `navigate_or_reload_child_browsing_context` should only ↵yvt2021-08-031-6/+2
| | | | | | | | | | handle cases involving navigation The initial document creation does not involve navigation, and it would cause a confusion if this was done by a function which has `navigation` in its name. This commit renames `navigate_or_reload_child_browsing_ context` to `start_new_pipeline`, and introduces a new function which has the original name and is dedicated to handle navigation.
* Auto merge of #28546 - yvt:feat-cow-infra, r=jdmbors-servo2021-08-011-3/+0
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement `Location`'s custom internal methods This PR partly resurrects #16501 and introduces the use of principals object to associate objects and Realms with origins. Using this infrastructure, this PR implements [the custom internal methods][1] of the `Location` interface, which is "maybe-cross-origin". Unimplemented/incomplete things: - Other maybe-cross-origin interfaces, namely `WindowProxy` and `DissimilarWindowLocation`, aren't implemented correctly yet (causing most test cases of `tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html` to fail). - `WindowProxy`: #28556 - [The "perform a security check" operation][2] and `Location`'s non-cross-origin properties' relevant `Document` origin checks aren't implemented either (not sure if they are covered by the existing tests). - There are a slight deviation from the standard and inefficiency in `CrossOriginGetOwnPropertyHelper`'s current implementation. - #28557 [1]: https://html.spec.whatwg.org/multipage/#the-location-interface [2]: https://html.spec.whatwg.org/multipage/browsers.html#integration-with-idl --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16243 and make some progress in #2382 --- - [x] There are tests for these changes OR - [ ] These changes do not require tests because ___
| * feat(script): remove the call to `JS_SetWrapObjectCallbacks`yvt2021-07-111-3/+0
| | | | | | | | We don't make CCWs anymore.
* | feat: shorten thread namesyvt2021-07-191-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Linux kernel imposes a 15-byte limit on thread names[1]. This means information that does not fit in this limit, e.g., the pipeline ID of layout and script threads, is lost in a debugger and profiler (see the first column of the table below). This commit shortens the thread names used in Servo to maximize the amount of information conveyed. It also rectifies some inconsistencies in the names. | Before | After | |-------------------|-------------------| | `BluetoothThread` | `Bluetooth` | | `CanvasThread` | `Canvas` | | `display alert d` | `AlertDialog` | | `FontCacheThread` | `FontCache` | | `GLPlayerThread` | `GLPlayer` | | `HTML Parser` | `Parse:www.examp` | | `LayoutThread Pi` | `Layout(1,1)` | | `Memory profiler` | `MemoryProfiler` | | `Memory profiler` | `MemoryProfTimer` | | `OfflineAudioCon` | `OfflineACResolv` | | `PullTimelineMar` | `PullTimelineDat` | | `ScriptThread Pi` | `Script(1,1)` | | `WebWorker for h` | `WW:www.example.` | | `ServiceWorker f` | `SW:www.example.` | | `ServiceWorkerMa` | `SvcWorkerManage` | | `Time profiler t` | `TimeProfTimer` | | `Time profiler` | `TimeProfiler` | | `WebGL thread` | `WebGL` | | `Choose a device` | `DevicePicker` | | `Pick a file` | `FilePicker` | | `Pick files` | `FilePicker` | [1]: https://stackoverflow.com/questions/5026531/thread-name-longer-than-15-chars
* fmtteymour-aldridge2021-02-051-11/+2
|
* Remove unused arguments from methods.teymour-aldridge2021-02-051-4/+1
|
* Fix errorsteymour-aldridge2021-02-051-24/+32
|
* Fix `document.characterSet` not reflecting byte order marks.Andreu Botella2020-12-311-4/+2
| | | | | | | | | | | | | The process of decoding the network byte stream to Unicode is backed by an instance of `encoding_rs::Decoder`, which will switch the encoding it uses if it finds a BOM in the byte stream. However, this change in encoding is not communicated back to the caller and so `document.characterSet` gives the wrong result. This change fixes that. See whatwg/html#5359 and whatwg/encoding#203 for the spec-level backing for this change. Signed-off-by: Andreu Botella <abb@randomunok.com>
* Add creation url and Secure ContextsJonathan Kingston2020-11-251-0/+14
|
* Do not load srcdoc iframes synchronouslyUtsav Oza2020-08-051-4/+7
|
* Implement GPURenderBundleEncoder and GPURenderBundleKunal Mohan2020-07-241-0/+1
|
* Auto merge of #27026 - CYBAI:dynamic-module, r=jdmbors-servo2020-07-191-1/+7
|\ | | | | | | | | | | | | | | | | | | Introduce dynamic module --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #25439 - [x] There are tests for these changes
| * Set private reference for classic scriptCYBAI2020-07-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | Web developers can use `Dynamic Import` in a classic script; thus, we need to save the script's private reference so that we can reuse it when we're going to fetch a dynamic import module for a classic script. Besides, because it's possible to use different executing context for a dynamic import module (like `dynamic-import/string-compilation-other-document.html` WPT test), we can't initialize a module owner at the timing of `SetScriptPrivate`; thus, if the private module script doesn't hold an owner, we'll use a DynamicImport owner for it.
* | Ensure GPUDevice cleanup in GlobalScopeKunal Mohan2020-07-171-0/+7
| |
* | Implement Async Error reporting for WebGPU and update wgpu-coreKunal Mohan2020-07-161-0/+9
|/
* Unfocus input when virtual keyboard is dismissedPaul Rouget2020-07-131-2/+10
|
* Auto merge of #27163 - ↵bors-servo2020-07-041-6/+13
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | alarsyo:23053-layout-queries-disconnected-frames-panic, r=jdm 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 #26969 FIX #26429 FIX #21208 FIX #19092 FIX #22559 FIX #22584 FIX #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?
| * Return Option for Window's layout channelAntoine Martin2020-07-031-6/+13
| |
* | Propagate referrer policy during about:srcdoc page loadUtsav Oza2020-07-021-3/+4
|/
* ensure clean shutdown of all threads running JSGregory Terzian2020-06-301-38/+129
|
* Auto merge of #26926 - MDeiml:referrer-26570, r=jdmbors-servo2020-06-191-2/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make url for "client" referrer mandatory <!-- Please describe your changes on the following line: --> I added a url attribute to `Referrer::Client` so that the referrer header can be set accordingly when fetching. `Referrer::Client` has to be kept separate from `Referrer::ReferrerUrl` as they differ in this method https://github.com/servo/servo/blob/6b0d9afd6fdc28356ad44af0104ddd25a7b6438d/components/script/dom/request.rs#L566-L576 --- <!-- 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 #26570 (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. -->
| * Make url for "client" referrer mandatoryMatthias Deiml2020-06-171-2/+1
| |
* | Auto merge of #26955 - gterzian:fix_parser_borrow, r=jdmbors-servo2020-06-171-6/+8
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not trace pending parsers <!-- Please describe your changes on the following line: --> FIX https://github.com/servo/servo/issues/26857 --- <!-- 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. -->
| * do not trace pending parsersGregory Terzian2020-06-171-6/+8
| |
* | Make clicking on an element request focus for focusable elements.Josh Matthews2020-06-151-3/+1
|/
* reading unminified scripts from diskskrzyp12020-06-021-0/+8
|
* Implement GPUTexture and GPUTextureViewKunal Mohan2020-06-011-0/+2
|
* Implement GPURenderPipelineKunal Mohan2020-05-301-0/+1
| | | | Add webidl for GPURenderPipeline and implement GPUDevice.createRenderPipeline()
* Auto merge of #26659 - mrobinson:events, r=jdmbors-servo2020-05-271-157/+8
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for remaining animation and transition events This PR adds support for remaining animation and transitions events. There are two commits here. The first is a bit more complicated: it reworks how rooting is done for animating nodes. Instead of having the `ScriptThread` try to track which animations are active via events (which can be inaccurate), it just maintains roots for nodes that are actually present in the animations- -related data structures. The second commit adds support for the new events. Unfortunately, the existing events tests either rely on the Web Animations API or other behavior (for example, that changing animation delay restarts an animation). Since those two things are out-of-scope for this change, I've forked some of the WPT tests, removed the reliance on the Web Animations API, and added them to Servo's internal tests. --- <!-- 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 #21564. - [x] There are tests for these changes OR <!-- 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. -->
| * Have Animations struct handle rooting nodesMartin Robinson2020-05-261-157/+8
| | | | | | | | | | | | | | Instead of having `ScriptThread` handle rooting nodes, do this in `Animations`. This makes it easier to know when it is appropriate to root and unroot nodes instead of relying on a certain order of events. This also allows reducing quite a bit the amount of unsafe code.
* | Make WebGPU resource creation fully asyncKunal Mohan2020-05-261-0/+1
|/ | | | | Remove some garbage code in adapter id checks Prevent panic during shutdown if using WebGPU
* Add GPUSampler to WebGPU implementationKunal Mohan2020-05-261-0/+1
| | | | Add dom_struct and webidl for GPUSampler, implement GPUDevice.createSampler() method.
* Implement client-side logic for WebGPU id recyclingKunal Mohan2020-05-221-3/+52
|