mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
attempt to limit memory size used by PNG decoder
still getting a heap allocation failure, something is looking for 256k and even when the heap is increased to a couple megabytes we get heap allocation failures.
This commit is contained in:
parent
fdcadf35dd
commit
e504e9b89c
2 changed files with 18 additions and 12 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -1133,16 +1133,6 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fast_image_resize"
|
|
||||||
version = "0.9.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ccf174e621dc44fc6118d0e3289a1286c166ac28599e15651a82da23a14a3425"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
"thiserror",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "1.7.0"
|
version = "1.7.0"
|
||||||
|
|
@ -2061,7 +2051,6 @@ name = "modals"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit_field 0.9.0",
|
"bit_field 0.9.0",
|
||||||
"fast_image_resize",
|
|
||||||
"gam",
|
"gam",
|
||||||
"locales",
|
"locales",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
||||||
|
|
@ -380,11 +380,14 @@ impl<'a> ShellCmdApi<'a> for NetCmd {
|
||||||
let modals = modals::Modals::new(&env.xns).unwrap();
|
let modals = modals::Modals::new(&env.xns).unwrap();
|
||||||
// have to add 4 to the start because the index is at the beginning of the header sequence,
|
// have to add 4 to the start because the index is at the beginning of the header sequence,
|
||||||
// not the end of the sequence.
|
// not the end of the sequence.
|
||||||
|
log::info!("heap size: {}", heap_usage());
|
||||||
log::info!("decoding png starting with: {:x?}", &received[start+4..start+4+64]);
|
log::info!("decoding png starting with: {:x?}", &received[start+4..start+4+64]);
|
||||||
let decoder = png::Decoder::new(&received[start+4..]);
|
let decoder = png::Decoder::new_with_limits(&received[start+4..], png::Limits { bytes: 400 * 1024 });
|
||||||
|
log::info!("heap size: {}", heap_usage());
|
||||||
let mut reader = decoder.read_info().expect("failed to read png info");
|
let mut reader = decoder.read_info().expect("failed to read png info");
|
||||||
let mut buf = vec![0; reader.output_buffer_size()];
|
let mut buf = vec![0; reader.output_buffer_size()];
|
||||||
let info = reader.next_frame(&mut buf).expect("failed to decode png");
|
let info = reader.next_frame(&mut buf).expect("failed to decode png");
|
||||||
|
log::info!("heap size: {}", heap_usage());
|
||||||
|
|
||||||
let (width, height) = (info.width, info.height);
|
let (width, height) = (info.width, info.height);
|
||||||
log::info!("image is {} x {}", width, height);
|
log::info!("image is {} x {}", width, height);
|
||||||
|
|
@ -701,3 +704,17 @@ impl Worker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="ditherpunk")]
|
||||||
|
fn heap_usage() -> usize {
|
||||||
|
match xous::rsyscall(xous::SysCall::IncreaseHeap(0, xous::MemoryFlags::R)).expect("couldn't get heap size") {
|
||||||
|
xous::Result::MemoryRange(m) => {
|
||||||
|
let usage = m.len();
|
||||||
|
usage
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::error!("Couldn't measure heap usage");
|
||||||
|
0
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue