mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
Any RenderingContext/OffscreenRenderingContext type has readonly "canvas" attribute and associated native-code DOM context objects have reference to target DOM canvas objects. https://html.spec.whatwg.org/multipage/canvas.html#renderingcontext https://html.spec.whatwg.org/multipage/canvas.html#offscreenrenderingcontext And currently the reference to DOM canvas object is the rooting pointer on the stack, which leads to the circular reference problem. The SpiderMonkey's (SM) garbage collector will not be able to free the DOM canvas and context objects (unreacheble from JS) because of the rooting pointer on stack (see STACK_ROOTS). And these objects will be stored until the associated script runtime/thread will be terminated. SM -> JS Roots -> DOM Canvas* (on heap) -> DOM Context (on heap) SM -> Rust Roots -> Dom Canvas* (on stack) <- as "canvas" member field Let's replace the rooting pointer to the traceble pointer (DomRoot -> Dom) in the "canvas" member field of DOM context object, which allows to broke circular referencing problem. Testing: No changes in existed tests Signed-off-by: Andrei Volykhin <volykhin.andrei@huawei.com> Co-authored-by: Andrei Volykhin <volykhin.andrei@huawei.com>
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
use dom_struct::dom_struct;
|
|
use webrender_api::ImageKey;
|
|
|
|
use crate::canvas_context::LayoutCanvasRenderingContextHelpers;
|
|
use crate::dom::bindings::codegen::Bindings::GPUCanvasContextBinding::GPUCanvasContextMethods;
|
|
use crate::dom::bindings::codegen::UnionTypes::HTMLCanvasElementOrOffscreenCanvas as RootedHTMLCanvasElementOrOffscreenCanvas;
|
|
use crate::dom::bindings::reflector::Reflector;
|
|
use crate::dom::bindings::root::LayoutDom;
|
|
|
|
#[dom_struct]
|
|
pub(crate) struct GPUCanvasContext {
|
|
reflector_: Reflector,
|
|
}
|
|
|
|
impl GPUCanvasContext {
|
|
#[allow(dead_code)]
|
|
fn new_inherited() -> Self {
|
|
unimplemented!()
|
|
}
|
|
}
|
|
|
|
impl GPUCanvasContextMethods<crate::DomTypeHolder> for GPUCanvasContext {
|
|
/// <https://gpuweb.github.io/gpuweb/#dom-gpucanvascontext-canvas>
|
|
fn Canvas(&self) -> RootedHTMLCanvasElementOrOffscreenCanvas {
|
|
unimplemented!()
|
|
}
|
|
}
|
|
|
|
impl LayoutCanvasRenderingContextHelpers for LayoutDom<'_, GPUCanvasContext> {
|
|
fn canvas_data_source(self) -> Option<ImageKey> {
|
|
unimplemented!()
|
|
}
|
|
}
|