Skip to content

Commit

Permalink
Avoid fetching node global from HTMLMediaElement's destructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Feb 24, 2020
1 parent f02e516 commit 2e6252f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions components/script/dom/htmlmediaelement.rs
Expand Up @@ -74,7 +74,7 @@ use html5ever::{LocalName, Prefix};
use http::header::{self, HeaderMap, HeaderValue};
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use media::{glplayer_channel, GLPlayerMsg, GLPlayerMsgForward};
use media::{glplayer_channel, GLPlayerMsg, GLPlayerMsgForward, WindowGLContext};
use net_traits::image::base::Image;
use net_traits::image_cache::ImageResponse;
use net_traits::request::{Destination, Referrer};
Expand Down Expand Up @@ -373,6 +373,8 @@ pub struct HTMLMediaElement {
/// the access to the "privileged" document.servoGetMediaControls(id) API by
/// keeping a whitelist of media controls identifiers.
media_controls_id: DomRefCell<Option<String>>,
#[ignore_malloc_size_of = "Defined in other crates"]
player_context: WindowGLContext,
}

/// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate>
Expand Down Expand Up @@ -437,6 +439,7 @@ impl HTMLMediaElement {
current_fetch_context: DomRefCell::new(None),
id: Cell::new(0),
media_controls_id: DomRefCell::new(None),
player_context: document.window().get_player_context(),
}
}

Expand Down Expand Up @@ -1967,15 +1970,14 @@ impl HTMLMediaElement {

impl Drop for HTMLMediaElement {
fn drop(&mut self) {
let window = window_from_node(self);
window.get_player_context().glplayer_chan.map(|pipeline| {
if let Some(ref pipeline) = self.player_context.glplayer_chan {
if let Err(err) = pipeline
.channel()
.send(GLPlayerMsg::UnregisterPlayer(self.id.get()))
{
warn!("GLPlayer disappeared!: {:?}", err);
}
});
}

self.remove_controls();
}
Expand Down

0 comments on commit 2e6252f

Please sign in to comment.