aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/dedicatedworkerglobalscope.rs
Commit message (Collapse)AuthorAgeFilesLines
* chore: Update wgpu (#33506)Samson2024-09-211-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | * Update wgpu Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * use all backends at runtime Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * clean up some adapter stuff Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * flakes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Make CanGc derive Copy and Clone (#33407)Taym Haddadi2024-09-121-2/+2
| | | Signed-off-by: Taym <haddadi.taym@gmail.com>
* Propagate `CanGc` from `Document::new()` (#33386)Andriy Sultanov2024-09-091-3/+4
| | | | | | | | | | | | | * Add canGc as a parameter to autogenerated trait methods Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com> * Propagate CanGc from Document::new() Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com> --------- Signed-off-by: Andriy Sultanov <sultanovandriy@gmail.com>
* Initial structuredClone implementation (#32960)Taym Haddadi2024-08-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | * Initial structuredClone implementation Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Rename PostMessageOptions to StructuredSerializeOptions Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Update wpt test 2020 layout result Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Remove dublicated StructuredClone implementation Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> * Remove comment from StructuredSerializeOptions webidl Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com> --------- Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com> Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
* webgpu: Remove mutex around Identities (#32682)派卡 (pi-cla)2024-07-031-4/+3
|
* clippy fixes regarding clone_from (#32482)Peter Mikola2024-06-121-1/+4
|
* Move non-gfx things out of `gfx_traits` and create a `base` crate (#32296)Martin Robinson2024-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | For a long time, `gfx_traits` has held a lot of things unrelated to graphics and also unrelated to the `gfx` crate (which is mostly about fonts). This is a cleanup which does a few things: 1. Move non `gfx` crate things out of `gfx_traits`. This is important in order to prevent dependency cycles with a different integration between layout, script, and fonts. 2. Rename the `msg` crate to `base`. It didn't really contain anything to do with messages and instead mostly holds ids, which are used across many different crates in Servo. This new crate will hold the *rare* data types that are widely used. Details: - All BackgroundHangMonitor-related things from base to a new `background_hang_monitor_api` crate. - Moved `TraversalDirection` to `script_traits` - Moved `Epoch`-related things from `gfx_traits` to `base`. - Moved `PrintTree` to base. This should be widely useful in Servo. - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it to `WebRenderFontApi`.
* Fix some clippy warnings in `components/gfx` and `components/script` (#32215)Pi-Cla2024-05-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * clippy: Squish warnings and errors in gfx warning: redundant closure (gfx/font.rs:415:18) warning: useless conversion to the same type (gfx/font.rs:534:9) warning: the following explicit lifetimes could be elided: 'a (gfx/font.rs:619:16) error: this loop never actually loops (gfx/font_cache_thread.rs:112:9) warning: this expression creates a reference which is immediately dereferenced by the compiler (gfx/font_cache_thread.rs:229:51) warning: redundant closure (gfx/font_cache_thread.rs:551:18) 3 instances of: warning: casting integer literal to `f64` is unnecessary (gfx/platform/freetype/font_list.rs:271-273) * clippy: methods called `from_*` usually take no `self` It reports that by standard convention, from_* methods should not take any `&self` parameter * clippy: you should consider adding a `Default` implementation It reports that public types with a pub fn new() -> Self should have a Default implementation since they can be constructed without arguments * clippy: casting to the same type is unnecessary (`f32` -> `f32`) * clippy: use of `unwrap_or_else` to construct default value * clippy: methods called `is_*` usually take `self` by mutable reference or `self` by reference or no `self` * clippy: manual `!RangeInclusive::contains` implementation contains expresses the intent better and has less failure modes (such as fencepost errors or using || instead of &&) * clippy: this function has an empty `#[must_use]` attribute, but returns a type already marked as `#[must_use]` * clippy: Fix some new warnings warning: this `if` statement can be collapsed (gfx/font.rs:468:130) warning: this lifetime isn't used in the impl (gfx/platform/freetype/font.rs:341:6) warning: field assignment outside of initializer for an instance created with Default::default() (compositor.rs:881:17)
* Clippy: Fix the error of variants having the same prefix. (#31953)Aarya Khandelwal2024-04-051-13/+10
| | | | | | | | | | | | | | | | | | | * fix error: all variants have same prefix * made the suggested changes * fixed errors caused by commit * silenced the clippy warning. * ran ./mach fmt * Update components/script/dom/htmlmediaelement.rs Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com> --------- Co-authored-by: Samson <16504129+sagudev@users.noreply.github.com>
* clippy: Allow `too_many_arguments` for existing functions (#31974)eri2024-04-021-3/+4
| | | | | * Allow `too_many_arguments` for existing functions * fix: Surround ASCII with code block in rustdoc
* fix redundant closures in component/script/dom (#31917)Ekta Siwach2024-03-281-3/+1
| | | | | | | | | | | | | * fixed unnecessary conversions * resolved conflicts * resolved conflicts * fix redundant closures in component/script/dom * resolved conflicts * fixed formatting
* fixes dereferencing on an immutable reference (#31864)Aarya Khandelwal2024-03-261-1/+1
|
* changed `match` to 'matches!' (#31850)Aarya Khandelwal2024-03-251-4/+1
|
* clippy: Fix needless borrow warnings (#31813)Oluwatobi Sofela2024-03-211-3/+3
|
* clippy: Fix redundant field names warnings (#31793)Oluwatobi Sofela2024-03-201-4/+4
|
* rustdoc: Fix many rustdoc errors (#31147)Martin Robinson2024-01-221-2/+2
| | | | This fixes many rustdoc errors that occur due to raw URLs in rustdoc comments as well as unescaped Rust code that should be in backticks.
* Script: ensure child JS runtimes are dropped before parent (#30896)Gregory Terzian2024-01-041-0/+3
| | | | | | | | | | | * clear js runtime of dedicated worker that immediately exits * dedicated worker: clear js runtime if loading script fails * when the script thread crashes, deallocate worker runtimes before dropping main runtime * clear runtime if service worker script fails to load * ensure worker enter their realm before executing script
* Strict import formatting (grouping and granularity) (#30325)Samson2023-09-111-25/+28
| | | | | * strict imports formatting * Reformat all imports
* No tracing of nop traceable fields (#29926)Samson2023-08-041-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* Fix race condition and other issues related to Worker destruction. (#30066)Mukilan Thiyagarajan2023-08-031-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix race condition in Worker destruction During shutdown, the main script thread calls JS_RequestInterruptCallback(cx) for each worker thread it owns where cx is the JSContext* created for that worker. Although JS_RequestInterruptCallback is safe to call from threads other than the worker thread, it is possible the JSContext* has already been destroyed For example, as noted in #30022, since the main thread sets the worker's `closing` flag to true to signal termination before it calls JS_RequestInterruptCallback, we can have a race condition where the worker exits its event loop when `closing` flags is set and then it (worker thread) destroys its own JSContext and JSRuntime. When the main thread resumes, it will call JS_RequestInterruptCallback for the worker's context, leading to a use-after-free bug. This patch solves this issue by improving the existing `ContextForRequestInterrupt` abstraction used for sharing the Worker's associated JSContext* with the parent script thread. Instead of simply wrapping a plain `*mut JSContext`, we now wrap the `*mut JSContext` in a nullable mutex i.e Mutex<Option<*mut JSContext>> The mutex lock needs to be held by the parent thread when it calls JS_RequestInterruptCallback. Similary, before the worker destroys its JSContext, it locks and sets the Option to None, signaling that the JSContext can no longer be used for interrupting the worker. This patch also fixes the issue in #30052 by enforcing the use of ContextForRequestInterrupt abstraction which ensures the correct JSContext is used by the main thread when Worker.terminate is called. Fixes #30022, #30052 * Fix Worker.importScripts to handle termination Fixing #30052 uncovered this issue in the implementation of `importScripts` method. After the fix for #30052, the WPT test `/workers/Worker-terminate-forever-during-evaluation.html` started to crash because when evaluation doesn't succeed `importScripts` always returns Error::JSFailed code to the caller, which indicates that there is a Dom/JS exception to be thrown. However, this is not true when the script is terminated, which causes the generated binding layer for 'importScript` to fail the assertion that there is a pending exception. This patch makes `importScripts` work similar to the [logic that evaluates the top-level script][1] of the Worker - it simply prints `evaluate_script failed - (terminated)' if the worker is terminating [1]: https://github.com/servo/servo/blob/3fea90a231a94338d67712398fe3d2ba9d402211/components/script/dom/workerglobalscope.rs#L434
* feat: shorten thread namesyvt2021-07-191-2/+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
* doc(script): use the recommended format of a WHATWG linkyvt2021-07-131-1/+1
| | | Enforced by `./mach test-tidy`
* doc(script): update comments in `run_worker_scope` and `run_serviceworker_scope`yvt2021-07-131-1/+1
| | | | | | | The step numbers changed over time. Note that service workers and non-service workers use different steps defined in different specifications.
* fix(script): Set `DedicatedWorkerGlobalScope`'s origin correctlyyvt2021-07-131-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <https://html.spec.whatwg.org/multipage/workers.html#worker-processing-model> > 10.2.4 Processing model > > When a user agent is to run a worker for a script with `Worker` or > `SharedWorker` object `worker`, [...] it must run the following steps. > > [...] > > 8. Set up a worker environment settings object with `realm execution > context` and `outside settings`, and let `inside settings` be the > result. <https://html.spec.whatwg.org/multipage/workers.html#script-settings-for-workers> > To **set up a worker environment settings object**, given a JavaScript > execution context `execution context` and environment settings object > `outside settings`: > > 1. Let `inherited origin` be `outside settings`'s origin. > > 2. Let `realm` be the value of `execution context`'s Realm component. > > 3. Let `worker global scope` be `realm`'s global object. > > 4. Let `settings object` be a new environment settings object whose > algorithms are defined as follows: > > **The origin** Return a unique opaque origin if `worker global > scope`'s url's scheme is "data", and `inherited origin` otherwise.
* ensure clean shutdown of all threads running JSGregory Terzian2020-06-301-2/+6
|
* Make url for "client" referrer mandatoryMatthias Deiml2020-06-171-3/+5
|
* properly shutdown dedicated workers when the owning scope shuts-downGregory Terzian2020-06-031-0/+1
|
* add a control chan to workers, use to signal shutdownGregory Terzian2020-06-031-3/+33
|
* add mechanism to join on service- and dedicated-worker threadsGregory Terzian2020-05-291-3/+3
|
* check http_state in determine_request_referrerAlexandrov Sergey2020-05-191-0/+4
|
* Share single gpu_id_hub among all threads in a processKunal Mohan2020-05-151-0/+8
|
* Support connecting to worker globals from remote devtools.Josh Matthews2020-04-281-1/+13
|
* Always pass InRealm to GlobalScope::from_context to avoid getting null globalCYBAI2020-02-161-3/+5
|
* rename compartment to realmKunal Mohan2020-01-241-1/+1
|
* Remove `origin` parameter from `Worker::handle_message`Kunal Mohan2020-01-041-2/+1
|
* Auto merge of #24123 - gterzian:redo_blob, r=jdmbors-servo2019-12-191-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restructure Blob, structured serialization <!-- Please describe your changes on the following line: --> FIX #24052 and also address the "cloning" half of FIX #23917 --- <!-- 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. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24123) <!-- Reviewable:end -->
| * re-structure blob, structured serializationGregory Terzian2019-12-111-1/+1
| |
* | Remove Optional pipeline_idWarren Fisher2019-12-191-14/+10
| |
* | devtools: save and send cached messagesPaul Rouget2019-12-061-3/+0
|/
* Auto merge of #24758 - gterzian:impl_timer_task_source, r=noxbors-servo2019-11-261-43/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement timer-task-source, time-out service worker <!-- Please describe your changes on the following line: --> Implements the timer task-source, and folds the IPC glue-code into a single route set by the globalscope. Also switches service worker to using a dedicated "time-out" mechanism, which previously relied on the timer mechanism(and I think didn't actually implement script timers). --- <!-- 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 #24747 (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. -->
| * impl timer-task-source, dedicated time-out mechanism for service-workerGregory Terzian2019-11-191-43/+2
| |
* | Ensure JS runnables are dispatched to a worker's event loop instead of its ↵Josh Matthews2019-11-221-4/+8
| | | | | | | | parent.
* | Bind runnable dispatching in script_runtimeAkash-Pateria2019-11-191-1/+11
|/
* Use IDL sequence default valueKagami Sascha Rosylight2019-11-041-2/+0
|
* continue messageport, transferable, postmessage optionsGregory Terzian2019-10-191-30/+70
|
* begin messageport, transferable objects, implKeith Yeung2019-10-191-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Accept transfer argument for StructuredCloneData::write Allow structured clone reads to return a boolean Add Transferable trait Add basic skeletons to MessagePort Implement transfer and transfer-receiving steps on MessagePort Use transfer and transfer_receive in StructuredClone callbacks Implement MessageChannel Freeze the array object for the MessageEvent ports attribute Implement transfer argument on window.postMessage Use ReentrantMutex instead for MessagePortInternal Accept origin as a parameter in dispatch_jsval Fix BorrowMut crash with pending_port_message Detach port on closure and check for detached during transfer Enable webmessaging tests fix webidl fix
* Modify *::get_cx methods to return a safe JSContext instead of a raw onemarmeladema2019-07-241-2/+2
|
* Convert CGTraitInterface to use safe JSContext instead of raw JSContextmarmeladema2019-07-241-3/+2
|
* Wrap(Global)Method now takes a SafeJSContext instead of a JSContextmarmeladema2019-07-241-2/+4
| | | | as first argument.
* Create a helper API for entering a DOM object's compartmentKamil Niski2019-06-291-2/+3
| | | | | | Revert some unnecessary changes Fix fmt errors