mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
fix: ReadableStream::get_in_memory_bytes
too large (#36914)
Fix a IPC hang due to `ReadableStream::get_in_memory_bytes` could return really huge chunk. Testing: WPT on ReadableStream should pass Fixes: IPC hang when transferring huge chunk bytes from `ReadableStream` cc @gterzian @Taym95 since this is also related to ReadableStream. --------- Signed-off-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local> Co-authored-by: Yu Wei Wu <yuweiwu@YunoMacBook-Air.local>
This commit is contained in:
parent
c37d5572fd
commit
aa4ad0f2be
5 changed files with 29 additions and 20 deletions
|
@ -11,6 +11,7 @@ use std::rc::Rc;
|
|||
use base::id::{MessagePortId, MessagePortIndex};
|
||||
use constellation_traits::MessagePortImpl;
|
||||
use dom_struct::dom_struct;
|
||||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
use js::conversions::ToJSValConvertible;
|
||||
use js::jsapi::{Heap, JSObject};
|
||||
use js::jsval::{JSVal, NullValue, ObjectValue, UndefinedValue};
|
||||
|
@ -1131,12 +1132,14 @@ impl ReadableStream {
|
|||
|
||||
/// Return bytes for synchronous use, if the stream has all data in memory.
|
||||
/// Useful for native source integration only.
|
||||
pub(crate) fn get_in_memory_bytes(&self) -> Option<Vec<u8>> {
|
||||
pub(crate) fn get_in_memory_bytes(&self) -> Option<IpcSharedMemory> {
|
||||
match self.controller.borrow().as_ref() {
|
||||
Some(ControllerType::Default(controller)) => controller
|
||||
.get()
|
||||
.expect("Stream should have controller.")
|
||||
.get_in_memory_bytes(),
|
||||
.get_in_memory_bytes()
|
||||
.as_deref()
|
||||
.map(IpcSharedMemory::from_bytes),
|
||||
_ => {
|
||||
unreachable!("Getting in-memory bytes for a stream with a non-default controller")
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue