Closed conanchen closed 2 years ago
I am using the latest tauri @next ,
❯ git log commit e784ebca9f5513ce07b63c15ccac4f51c14efe2f (HEAD -> next, origin/next, origin/HEAD) Author: Lucas Fernandes Nogueira lucasfernandesnog@gmail.com Date: Thu Dec 30 13:46:05 2021 -0300
fix(core): Send+Sync for Window, closes #3135 (#3140)
commit efbf236f35a1dd4064c0615b56881e4132a249f4 Author: Lucas Fernandes Nogueira lucasfernandesnog@gmail.com Date: Thu Dec 30 11:28:41 2021 -0300
Thanks for the report. I'll look into this over the weekend.
I don't think the webview supports loading m3u8 files directly. I also tried on Chrome and on Safari and it didn't work. Do you see any evidence this might work?
asset::// protocol works with local m3u8 file. I added println! to manager.rs to check the range parsing
// handle 206 (partial range) http request
if let Some(range) = request.headers().get("range").cloned() {
let mut status_code = 200;
let path_for_data = path_for_data.clone();
println!("path_for_data={}",path_for_data);
let (headers, status_code, data) = crate::async_runtime::safe_block_on(async move {
let mut headers = HashMap::new();
let mut buf = Vec::new();
let mut file = tokio::fs::File::open(path_for_data.clone()).await.unwrap();
// Get the file size
let file_size = file.metadata().await.unwrap().len();
// parse the range
let range_ = HttpRange::parse(range.to_str().unwrap(), file_size);
println!("path_for_data file_size={} {:?} range_={:?}",file_size , range.to_str(), range_);
let range = range_.unwrap();
// FIXME: Support multiple ranges
and found it return an invalid range:
path_for_data file_size=375 Ok("bytes=0-*") range_=Err(InvalidRange)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidRange', /Users/CC/github/tauri-apps/tauri/core/tauri/src/manager.rs:352:32
2022-01-04 14:57:47.177643 UTC INFO may::io::sys::select - got wakeup event in select, id=0 path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=0-326743") range=Ok([HttpRange { start: 0, length: 326744 }]) path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=326744-653111") range=Ok([HttpRange { start: 326744, length: 326368 }]) path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=653112-980231") range=Ok([HttpRange { start: 653112, length: 327120 }]) path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=980232-1306787") range=Ok([HttpRange { start: 980232, length: 326556 }]) path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=1306788-1633155") range=Ok([HttpRange { start: 1306788, length: 326368 }]) path_for_data=/Users/CC/xxxx/bipbop-advanced/gear1/main.ts path_for_data filesize=59366640 Ok("bytes=1633156-1960839") range=Ok([HttpRange { start: 1633156, length: 327684 }])
path_for_data=/Users/CC/xxxx/bipbop-advanced/bipbop_16x9_variant.m3u8
path_for_data file_size=2326 Ok("bytes=0-*") range_=Err(InvalidRange)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidRange', /Users/CC/github/tauri-apps/tauri/core/tauri/src/manager.rs:352:32
stack backtrace:
0: 0x110d82001 - std::backtrace_rs::backtrace::libunwind::trace::hd1f3f27a0ce98cd1
at /rustc/efec545293b9263be9edfb283a7aa66350b3acbf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
2022-01-04 14:54:19.659310 UTC INFO may::io::sys::select - got wakeup event in select, id=0
path_for_data=/Users/CC/xxxxx/master.m3u8
path_for_data filesize=375 Ok("bytes=0-*") range=Err(InvalidRange)
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: InvalidRange', /Users/CC/github/tauri-apps/tauri/core/tauri/src/manager.rs:352:32
stack backtrace:
0: 0x1064e7001 - std::backtrace_rs::backtrace::libunwind::trace::hd1f3f27a0ce98cd1
at /rustc/efec545293b9263be9edfb283a7aa66350b3acbf/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x1064e7001 - std::backtrace_rs::backtrace::trace_unsynchronized::hd569a01ac3d00854
at /rustc/efec545293b9263be9edfb283a7aa66350b3acbf/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x1064e7001 - std::sys_common::backtrace::_print_fmt::h996dd958d6ad6e0c
at /rustc/efec545293b9263be9edfb283a7aa66350b3acbf/library/std/src/sys_common/backtrace.rs:67:5
3: 0x1064e7001 -
test with below updated manager.rs by checking file/range before unwrap(), works now.
// handle 206 (partial range) http request
if let Some(range) = request.headers().get("range").cloned() {
let mut status_code = 200;
let path_for_data = path_for_data.clone();
println!("path_for_data={}", path_for_data);
let (headers, status_code, data) = crate::async_runtime::safe_block_on(async move {
let mut headers = HashMap::new();
let mut buf = Vec::new();
let mut file = tokio::fs::File::open(path_for_data.clone()).await;
if file.is_ok() {
let mut file_ = file.unwrap();
// Get the file size
let file_size = file_.metadata().await.unwrap().len();
let file_size_ = format!("{}", file_size);
let ss = range.to_str().unwrap();
// parse the range
let range_ = HttpRange::parse(&ss.replace("*", &file_size_), file_size);
println!(
"path_for_data file_size={} {:?} range_={:?}",
file_size,
range.to_str(),
range_
);
let range = range_.unwrap();
// FIXME: Support multiple ranges
Describe the bug
currupt when loading local hls files with asset protocol
Reproduction
used convertFileSrc
{#if showPlayer}