Skip to content

Conversation

@jakobhellermann
Copy link
Contributor

@jakobhellermann jakobhellermann commented Mar 24, 2022

Currently tracy interprets the entire trace as one frame because the marker for frames isn't being recorded.

When an event with tracy.trace_marker=true is recorded, tracing-tracy will mark the frame as finished:
https://github.com/nagisa/rust_tracy_client/blob/aa0b96b2ae2aee6f3831994f9a3a8c29bcc85fae/tracing-tracy/src/lib.rs#L240

Unfortunately this leads to

INFO bevy_app:frame: bevy_app::app: finished frame tracy.frame_mark=true

being printed every frame (we can't use DEBUG because bevy_log sets max_release_level_info.

Instead of emitting an event that gets logged every frame, we can depend on tracy-client itself and call finish_continuous_frame!();

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Mar 24, 2022
@mockersf
Copy link
Member

Is it a good idea to depend on both tracy_client and tracing_tracy?

From their doc it seems they shouldn't be used both at the same time

Copy link
Contributor

@superdump superdump left a comment

Choose a reason for hiding this comment

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

Did you try using a tracing event with the frame marker but at the debug level or so? Does it just get filtered out before it gets sent to Tracy? I think that aspect was maybe why I didn't make a PR.

Perhaps if that is a negative side effect of using the tracing frame marker API, we could make a contribution to tracing-tracy to allow directly calling finish continuous frame for when an event or message or so is undesirable.

@jakobhellermann
Copy link
Contributor Author

Is it a good idea to depend on both tracy_client and tracing_tracy?

tracing_tracy uses tracy_client will call finish_continous_frame! when an event with tracy.frame_mark is recorded: https://github.com/nagisa/rust_tracy_client/blob/aa0b96b2ae2aee6f3831994f9a3a8c29bcc85fae/tracing-tracy/src/lib.rs#L240
So this PR is doing exactly the same, just without the event.

Did you try using a tracing event with the frame marker but at the debug level or so?

I tried but that didn't work in release mode as bevy_log enabled the max_release_level_info feature on tracing-subscriber.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Diagnostics Logging, crash handling, error reporting and performance analysis and removed S-Needs-Triage This issue needs to be labelled labels Mar 24, 2022
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

LGTM once you resolve the correct position of the frame end :)

@robtfm
Copy link
Contributor

robtfm commented Mar 24, 2022

just to note an alternative to using another import, we could also suppress the info logging for tracy events:

+++ b/crates/bevy_log/src/lib.rs
@@ -159,6 +159,11 @@ impl Plugin for LogPlugin {
             let tracy_layer = tracing_tracy::TracyLayer::new();

             let fmt_layer = tracing_subscriber::fmt::Layer::default();
+            #[cfg(feature = "tracing-tracy")]
+            let fmt_layer = fmt_layer.with_filter(
+                tracing_subscriber::filter::Targets::new().with_target("tracy", Level::ERROR),
+            );
+
             let subscriber = subscriber.with(fmt_layer);

             #[cfg(feature = "tracing-chrome")]

@superdump
Copy link
Contributor

@robtfm oh that’s a good find. I guess warnings would be ok

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Mar 29, 2022
@superdump
Copy link
Contributor

@jakobhellermann what do you think of @robtfm ’s suggestion?

@jakobhellermann
Copy link
Contributor Author

I switched to @robtfm's suggestion to use the event but exclude it from the fmt_layer and moved the marker to right after the surface is presented and the SurfaceTexture dropped.

@mockersf
Copy link
Member

mockersf commented Apr 8, 2022

bors r+

bors bot pushed a commit that referenced this pull request Apr 8, 2022
Currently `tracy` interprets the entire trace as one frame because the marker for frames isn't being recorded.

~~When an event with `tracy.trace_marker=true` is recorded, `tracing-tracy` will mark the frame as finished:
<https://github.com/nagisa/rust_tracy_client/blob/aa0b96b2ae2aee6f3831994f9a3a8c29bcc85fae/tracing-tracy/src/lib.rs#L240>~~

~~Unfortunately this leads to~~
```rs
INFO bevy_app:frame: bevy_app::app: finished frame tracy.frame_mark=true
```
~~being printed every frame (we can't use DEBUG because bevy_log sets `max_release_level_info`.~~

Instead of emitting an event that gets logged every frame, we can depend on tracy-client itself and call `finish_continuous_frame!();`
@bors bors bot changed the title bevy_app: add tracing event with tracy.frame_mark [Merged by Bors] - bevy_app: add tracing event with tracy.frame_mark Apr 8, 2022
@bors bors bot closed this Apr 8, 2022
aevyrie pushed a commit to aevyrie/bevy that referenced this pull request Jun 7, 2022
Currently `tracy` interprets the entire trace as one frame because the marker for frames isn't being recorded.

~~When an event with `tracy.trace_marker=true` is recorded, `tracing-tracy` will mark the frame as finished:
<https://github.com/nagisa/rust_tracy_client/blob/aa0b96b2ae2aee6f3831994f9a3a8c29bcc85fae/tracing-tracy/src/lib.rs#L240>~~

~~Unfortunately this leads to~~
```rs
INFO bevy_app:frame: bevy_app::app: finished frame tracy.frame_mark=true
```
~~being printed every frame (we can't use DEBUG because bevy_log sets `max_release_level_info`.~~

Instead of emitting an event that gets logged every frame, we can depend on tracy-client itself and call `finish_continuous_frame!();`
nfagerlund added a commit to nfagerlund/bevy that referenced this pull request Dec 14, 2022
Bevy was failing to print events from `info!()` and friends to the console if
the `trace_tracy` feature was enabled.

The problem was this per-layer filter that was added in bevyengine#4320 to suppress a
noisy per-frame event (which Tracy requires in order to properly close out a
frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`.
    - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove
  _everything_ that doesn't match an explicit target rule.
    - So, the filter _was_ silencing the noisy event, along with everything else.

This commit changes that filter to do what was probably intended in bevyengine#4320:
suppress any events more verbose than `ERROR` from `bevy_render::renderer`, but
allow anything else that already made it through the top-level filter_layer.
nfagerlund added a commit to nfagerlund/bevy that referenced this pull request Dec 14, 2022
Bevy was failing to print events from `info!()` and friends to the console if
the `trace_tracy` feature was enabled.

The problem was this per-layer filter that was added in bevyengine#4320 to suppress a
noisy per-frame event (which Tracy requires in order to properly close out a
frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`.
    - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove
  _everything_ that doesn't match an explicit target rule.
    - So, the filter _was_ silencing the noisy event, along with everything else.

This commit changes that filter to do what was probably intended in bevyengine#4320:
suppress any events more verbose than `ERROR` from `bevy_render::renderer`, but
allow anything else that already made it through the top-level filter_layer.
bors bot pushed a commit that referenced this pull request Dec 20, 2022
)

# Objective

Fixes #6862 (oh hey good catch @alice-i-cecile)

Bevy was failing to print events from `info!()` and friends to the console if the `trace_tracy` feature was enabled. It shouldn't be doing that.

## Solution

The problem was this per-layer filter that was added in #4320 to suppress a noisy per-frame event (which Tracy requires in order to properly close out a frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`. - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove _everything_ that doesn't match an explicit target rule. - So, the filter _was_ silencing the noisy event, along with everything else.

This PR changes that filter to do what was probably intended in #4320: suppress ~any events more verbose than `ERROR` from `bevy_render::renderer`~ the one problematically noisy event, but allow anything else that already made it through the top-level filter_layer.

Also, adds a comment to clarify the intent of that filter, since it's otherwise a bit opaque and required some research.

---

## Changelog

Fixed a bug that hid console log messages when the `trace_tracy` feature was enabled.
alradish pushed a commit to alradish/bevy that referenced this pull request Jan 22, 2023
…vyengine#6955)

# Objective

Fixes bevyengine#6862 (oh hey good catch @alice-i-cecile)

Bevy was failing to print events from `info!()` and friends to the console if the `trace_tracy` feature was enabled. It shouldn't be doing that.

## Solution

The problem was this per-layer filter that was added in bevyengine#4320 to suppress a noisy per-frame event (which Tracy requires in order to properly close out a frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`. - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove _everything_ that doesn't match an explicit target rule. - So, the filter _was_ silencing the noisy event, along with everything else.

This PR changes that filter to do what was probably intended in bevyengine#4320: suppress ~any events more verbose than `ERROR` from `bevy_render::renderer`~ the one problematically noisy event, but allow anything else that already made it through the top-level filter_layer.

Also, adds a comment to clarify the intent of that filter, since it's otherwise a bit opaque and required some research.

---

## Changelog

Fixed a bug that hid console log messages when the `trace_tracy` feature was enabled.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…vyengine#6955)

# Objective

Fixes bevyengine#6862 (oh hey good catch @alice-i-cecile)

Bevy was failing to print events from `info!()` and friends to the console if the `trace_tracy` feature was enabled. It shouldn't be doing that.

## Solution

The problem was this per-layer filter that was added in bevyengine#4320 to suppress a noisy per-frame event (which Tracy requires in order to properly close out a frame):

- The problem event's target was `"bevy_render::renderer"`, not `"tracy"`. - So, the filter wasn't specifically targeting the noisy event.
- Without a default, `tracing_subscriber::filter::Targets` will remove _everything_ that doesn't match an explicit target rule. - So, the filter _was_ silencing the noisy event, along with everything else.

This PR changes that filter to do what was probably intended in bevyengine#4320: suppress ~any events more verbose than `ERROR` from `bevy_render::renderer`~ the one problematically noisy event, but allow anything else that already made it through the top-level filter_layer.

Also, adds a comment to clarify the intent of that filter, since it's otherwise a bit opaque and required some research.

---

## Changelog

Fixed a bug that hid console log messages when the `trace_tracy` feature was enabled.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
Currently `tracy` interprets the entire trace as one frame because the marker for frames isn't being recorded.

~~When an event with `tracy.trace_marker=true` is recorded, `tracing-tracy` will mark the frame as finished:
<https://github.com/nagisa/rust_tracy_client/blob/aa0b96b2ae2aee6f3831994f9a3a8c29bcc85fae/tracing-tracy/src/lib.rs#L240>~~

~~Unfortunately this leads to~~
```rs
INFO bevy_app:frame: bevy_app::app: finished frame tracy.frame_mark=true
```
~~being printed every frame (we can't use DEBUG because bevy_log sets `max_release_level_info`.~~

Instead of emitting an event that gets logged every frame, we can depend on tracy-client itself and call `finish_continuous_frame!();`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Diagnostics Logging, crash handling, error reporting and performance analysis C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants