You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Puffin works in the browser, if you provide it with a custom now() function using puffin::ThreadProfiler::initialize(...). However, puffin_egui does not, since it internally uses std::time for timing, and this function gives 'error time is not implemented on this platform' when running it in the browser environment. This means that currently, puffin_egui is unusable in the browser, due to this small internal catch.
Describe the solution you'd like puffin_egui could use the puffin::ThreadProfiler's timing function since that one can be configured to something that works and would make puffin_eguijust work from a user's perspective.
Describe alternatives you've considered
I guess another option is that puffin_egui also provides a way to use a custom timing function that could be different to the one given to puffin.
Additional context
I hacked the proposed solution into puffin_egui to see if it would work and it does. It's a very rough solution and changes some types, so it's not necessarily PR-worthy.
fnrun_pack_pass_if_needed(&mutself,frame_view:&FrameView){// NOTE: This function contains changes compared to the original repository.// last_pack_pass is changed from Option<std::time::Instant> to Option<i64>.// 'now' is using the ThreadProfiler now function instead of the system time one. Note that I added a public `now_ns_fn()`// to the ThreadProfiler too to be able to access the timing function.let now = || ThreadProfiler::call(|tp| tp.now_ns_fn());let last_pack_pass = *self.last_pack_pass.get_or_insert_with(now);let time_in_ns_since_last_pack = (now() - last_pack_pass)asu128;if time_in_ns_since_last_pack > std::time::Duration::from_secs(1).as_nanos(){
puffin::profile_scope!("pack_pass");for frame inself.all_known_frames(frame_view){if !self.is_selected(frame_view, frame.frame_index()){
frame.pack();}}self.last_pack_pass = Some(now());}}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Puffin works in the browser, if you provide it with a custom
now()
function usingpuffin::ThreadProfiler::initialize(...)
. However,puffin_egui
does not, since it internally usesstd::time
for timing, and this function gives'error time is not implemented on this platform'
when running it in the browser environment. This means that currently,puffin_egui
is unusable in the browser, due to this small internal catch.Describe the solution you'd like
puffin_egui
could use thepuffin::ThreadProfiler
's timing function since that one can be configured to something that works and would makepuffin_egui
just work from a user's perspective.Describe alternatives you've considered
I guess another option is that
puffin_egui
also provides a way to use a custom timing function that could be different to the one given topuffin
.Additional context
I hacked the proposed solution into
puffin_egui
to see if it would work and it does. It's a very rough solution and changes some types, so it's not necessarily PR-worthy.The text was updated successfully, but these errors were encountered: