Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
The purpose of this PR is to demonstrate how puffin support can be integrated into Bevy. Currently, this PR is based on my fork of the
puffin
library which implements a tracing layer for puffin: EmbarkStudios/puffin#79. But regardless of whether thetracing
support lands intopuffin
itself or it'll be an independent crate, it's possible for Bevy to integratepuffin
as atracing
layer without replacingtracing
with an alternative crate such asprofiling
orpuffin
itself (but it might still be worth to discuss those as well).Solution
The current approach is to add the
puffin_tracing
crate (which isn't published atm) as an optional dependency and introduce a feature which passesPuffinLayer
as atracing-subscriber
layer. This implies that users will have to addpuffin
,bevy_egui
,puffin_egui
crates to their apps themselves so that Bevy can avoid depending on those directly.It would be fair to note that such integration can also exist outside of Bevy as a plugin (today, I also published one: https://github.com/mvlabat/bevy_puffin).
But it doesn't offer an ideal UX, as it's incompatible with Bevy'sLogPlugin
, which renders it impossible to use theDefaultPlugins
plugin group and makes users add those plugins manually.Alternatively, we can also allow users to customize
LogPlugin
by passing their own layers.To discuss
I noted that this change doesn't make Bevy depend on
puffin
itself (only onpuffin_tracing
, which still transitively depends onpuffin
though), but there still might be a valid reason to do that. For example, we can add a system which would callpuffin::GlobalProfiler::lock().new_frame();
. As a counter-argument, users may want to control marking a new frame themselves, but I can't imagine the use-cases for that yet.