mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix intermittent crashes in paint worklets (#30671)
Garbage collection means that the worklets might drop after the script head has been cleaned up. The worklet now caches the thread pool in the DOM object itself which should prevent it from needing to access script thread TLS when being cleaned up. The value is stored as a OnceCell to maintain the same lazy thread pool creation pattern as before. Fixes #25838. Fixes #25258.
This commit is contained in:
parent
c2af95d2fc
commit
f8ec3df495
76 changed files with 59 additions and 137 deletions
|
@ -29,6 +29,7 @@
|
|||
//! The `unsafe_no_jsmanaged_fields!()` macro adds an empty implementation of
|
||||
//! `JSTraceable` to a datatype.
|
||||
|
||||
use std::cell::OnceCell;
|
||||
use std::collections::hash_map::RandomState;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
|
@ -89,6 +90,12 @@ unsafe impl<T: CustomTraceable> CustomTraceable for DomRefCell<T> {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe impl<T: JSTraceable> CustomTraceable for OnceCell<T> {
|
||||
unsafe fn trace(&self, tracer: *mut JSTracer) {
|
||||
self.get().map(|value| value.trace(tracer));
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper type for nop traceble
|
||||
///
|
||||
/// SAFETY: Inner type must not impl JSTraceable
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue