EmbarkStudios / puffin

🐦 Friendly little instrumentation profiler for Rust 🦀
Apache License 2.0
1.47k stars 72 forks source link

Viewer labeling scopes wrong when restarting app #215

Closed Firestar99 closed 2 months ago

Firestar99 commented 3 months ago

Describe the bug When you restart the application that you're profiling and have removed or otherwise changed the profiling scopes, puffin_viewer will mislabel the scopes. Specifically, every scope that follows the removed scope in initialization order will be labeled as the previous scope in initialization order. This can be especially bad in multithreaded applications where scope initialization order can differ between application restarts, without having to change the code at all.

Workaround: Restarting puffin_viewer each time you profile.

To Reproduce Steps to reproduce the behavior:

  1. Start puffin_viewer
  2. In this repo, run the server example with cargo run --example server
  3. Observe the viewer showing correct profile data
  4. Remove the following profile scope from puffin_http/examples/server.rs line 16:
    puffin::profile_scope!("main_loop", format!("frame {frame_counter}"));
  5. restart only the server
  6. Observe the viewer mislabeling all scopes

Expected behavior The profiler correctly labeling all scopes :D

Screenshots First run: image

Second run with a scope removed: image

Device:

Additional context Thanks for making this simple yet awesome profiler :heart:

Also it would be nice if you'd add to puffin_viewer's readme that sudo apt install libgtk-3-dev is required on Linux. Thanks

Firestar99 commented 3 months ago

It seems to be a UI-only bug, as saving and reloading the capture fixes the labeling