Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist viewer state #186

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ set -eux
# Checks all tests, lints etc.
# Basically does what the CI does.

cargo check --workspace --all-targets
cargo test --workspace --doc
cargo check --workspace --all-targets --all-features
cargo check -p puffin_viewer --lib --target wasm32-unknown-unknown --all-features
cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::all
cargo test --workspace --all-targets --all-features
export RUSTDOCFLAGS="-D warnings" # https://github.com/emilk/egui/pull/1454

cargo check --quiet --workspace --all-targets
cargo test --quiet --workspace --doc
cargo check --quiet --workspace --all-targets --all-features
cargo check --quiet -p puffin_viewer --lib --target wasm32-unknown-unknown --all-features
cargo clippy --quiet --workspace --all-targets --all-features -- -D warnings -W clippy::all
cargo test --quiet --workspace --all-targets --all-features
cargo fmt --all -- --check

cargo doc -p puffin -p puffin_egui -p puffin_http -p puffin_viewer --lib --no-deps --all-features
cargo doc --quiet -p puffin -p puffin_egui -p puffin_http -p puffin_viewer --lib --no-deps --all-features

(cd puffin && cargo check --no-default-features --features "ruzstd")
(cd puffin && cargo check --no-default-features --features "packing")
(cd puffin && cargo check --quiet --no-default-features --features "zstd")
(cd puffin && cargo check --quiet --no-default-features --features "serialization")
5 changes: 3 additions & 2 deletions puffin_egui/src/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Default for Options {
frame_list_height: 48.0,
frame_width: 10.0,

merge_scopes: true,
merge_scopes: false, // off, because it really only works well for single-threaded profiling
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently unchecking this one each time I start puffin 🤦

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep me too


sorting: Default::default(),
filter: Default::default(),
Expand Down Expand Up @@ -691,8 +691,9 @@ fn paint_record(
suffix
)
} else {
// Note: we don't escape the scope data (`{:?}`), because that often leads to ugly extra backslashes.
format!(
"{}{} {:?} {:6.3} ms {}",
"{}{} '{}' {:6.3} ms {}",
prefix,
scope_name.as_str(),
scope_data.data,
Expand Down
4 changes: 3 additions & 1 deletion puffin_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ include = ["**/*.rs", "Cargo.toml", "README.md", "icon.png"]
crate-type = ["cdylib", "rlib"]

[dependencies]
puffin_egui = { version = "0.25.0", path = "../puffin_egui" }
puffin_egui = { version = "0.25.0", path = "../puffin_egui", features = [
"serde",
] }
puffin = { version = "0.19.0", path = "../puffin", features = [
"packing",
"serialization",
Expand Down
12 changes: 10 additions & 2 deletions puffin_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ pub struct PuffinViewer {
}

impl PuffinViewer {
pub fn new(source: Source) -> Self {
pub fn new(source: Source, storage: Option<&dyn eframe::Storage>) -> Self {
let profiler_ui = storage
.and_then(|storage| eframe::get_value(storage, eframe::APP_KEY))
.unwrap_or_default();

Self {
profiler_ui: Default::default(),
profiler_ui,
source,
error: None,
profile_self: false,
Expand Down Expand Up @@ -211,6 +215,10 @@ impl PuffinViewer {
}

impl eframe::App for PuffinViewer {
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, eframe::APP_KEY, &self.profiler_ui);
}

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
puffin::GlobalProfiler::lock().new_frame();

Expand Down
2 changes: 1 addition & 1 deletion puffin_viewer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn main() -> Result<(), eframe::Error> {
eframe::run_native(
"puffin viewer",
native_options,
Box::new(|_cc| Box::new(PuffinViewer::new(source))),
Box::new(|cc| Box::new(PuffinViewer::new(source, cc.storage))),
)
}

Expand Down
2 changes: 1 addition & 1 deletion puffin_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub async fn start(canvas_id: &str) -> Result<(), eframe::wasm_bindgen::JsValue>
.start(
canvas_id,
web_options,
Box::new(|_cc| Box::new(crate::PuffinViewer::new(crate::Source::None))),
Box::new(|cc| Box::new(crate::PuffinViewer::new(crate::Source::None, cc.storage))),
)
.await?;

Expand Down
Loading