From 6ebb73d9a42cc8c703b79a8fcbf76f4c56e1b5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Jim=C3=A9nez=20Moreno?= Date: Mon, 22 Jun 2020 17:10:22 +0200 Subject: [PATCH] Fix rooting issue --- components/script/dom/rtcdatachannel.rs | 4 ++-- components/script/dom/rtcpeerconnection.rs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs index 7cf42b0f5fc..052f3f13131 100644 --- a/components/script/dom/rtcdatachannel.rs +++ b/components/script/dom/rtcdatachannel.rs @@ -85,8 +85,6 @@ impl RTCDataChannel { binary_type: DomRefCell::new(DOMString::from("blob")), }; - peer_connection.register_data_channel(servo_media_id, &channel); - channel } @@ -107,6 +105,8 @@ impl RTCDataChannel { global, ); + peer_connection.register_data_channel(rtc_data_channel.servo_media_id, &*rtc_data_channel); + rtc_data_channel } diff --git a/components/script/dom/rtcpeerconnection.rs b/components/script/dom/rtcpeerconnection.rs index 5d84b155216..bd4ac712c96 100644 --- a/components/script/dom/rtcpeerconnection.rs +++ b/components/script/dom/rtcpeerconnection.rs @@ -35,7 +35,7 @@ use crate::dom::rtcpeerconnectioniceevent::RTCPeerConnectionIceEvent; use crate::dom::rtcsessiondescription::RTCSessionDescription; use crate::dom::rtctrackevent::RTCTrackEvent; use crate::dom::window::Window; -use crate::realms::InRealm; +use crate::realms::{enter_realm, InRealm}; use crate::task::TaskCanceller; use crate::task_source::networking::NetworkingTaskSource; use crate::task_source::TaskSource; @@ -161,6 +161,8 @@ impl WebRtcSignaller for RTCSignaller { let _ = self.task_source.queue_with_canceller( task!(on_data_channel_event: move || { let this = this.root(); + let global = this.global(); + let _ac = enter_realm(&*global); this.on_data_channel_event(channel, event); }), &self.canceller, @@ -314,7 +316,10 @@ impl RTCPeerConnection { let channel = if let Some(channel) = self.data_channels.borrow().get(&channel_id) { DomRoot::from_ref(&**channel) } else { - debug_assert!(false, "Got an event for an unregistered data channel"); + warn!( + "Got an event for an unregistered data channel {:?}", + channel_id + ); return; }; @@ -337,7 +342,7 @@ impl RTCPeerConnection { .insert(id, Dom::from_ref(channel)) .is_some() { - debug_assert!(false, "Data channel already registered"); + warn!("Data channel already registered {:?}", id); } }