EmbarkStudios/puffin

Panic -> crash

Opened this issue · 8 comments

Describe the bug
The more functions I profile the more often I get a panic from puffin.

To Reproduce
Unforutnatelly I do not have an reproducible example, I can share a game (15GB) and instructions...

Expected behavior
No panic.

Device:

  • OS: Windows 11

Additional context
panic:

.cargo\registry\src\index.crates.io-1cd66030c949c28d\puffin-0.19.0\src\frame_data.rs:455:18:
We should have an unpacked frame if we don't have a packed one

I suspect it might be related to the threading model I use, but I would still expect it to not panic.
The game have two threading options:

  • Do most things on main thread
    • this panic only very rarely
    • in this mode I call new_frame in main thread
    • and majority of profiling events happen in main thread too
    • egui::profiler_ui have its own thread, there is 32 threads, that have few profiling event
  • Rendering and game logic separated
    • the panic happens relatively often
    • in this mode I call new_frame in main thread again
    • but majority of profiling events happen in other threads
    • egui::profiler_ui have its own thread, there is 30 threads, that have few profiling event

With the above information provided, depending on the game's architecture plus your implementation of this crate, I suggest you have a look at #shared_memory and #Atomic_types.

@domatinio If you was trying to link some page/documentation github removed the links.
I think there isn't much I can do as an user of the library. I call puffin::set_scopes_on(true) to start it, I have puffin_egui::GlobalProfilerUi in gui thread to call .ui on, I call puffin::GlobalProfiler::lock().new_frame(), and puffin::profile_scope("...") to mark scopes to be profiled. Or is there something else I can do?

Why should "game's architecture" have any impact on this? Why is unpacker frame supposed to always exist, when packed one does not? I was not been able to figure that out from the code.

I am not sure if you was pointing to shared memory and atomic, to explain why it is panicking, or to point out, that I can do something about it, can you elaborate please?

What are the reasons puffin can panic for?

I have no idea, I can find the line https://github.com/EmbarkStudios/puffin/blob/main/puffin/src/frame_data.rs#L455 but I do not understand, why it should always pass.

Use pseudocode to represent the whole profiler. It will help you better understand the overall flow. I do not think i can help you any further. Good luck.

@domatinio why would I try to represent the profiler with pseudocode when the source code is available? Can you explain what exactly did you mean in more detail?

Hey @xNxExOx I'd be willing to give you a hand with debugging this one if you don't telling me what you need.

It would also be helpful to have the source along with it so I can debug, but I fully understand if you are concerned about stealing and don't wish to share it (since you've clearly put a lot of time and effort into it).

@v0x0g you can download the game here: https://skylords.eu/ and we do not have source code of the game itself, we replaced a DLL, to add profiling events to the game. If you would like to help with improving (and fixing) the game help would be welcome too :)