-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile-out excessive wgpu log messages statically #14116
Comments
previous discussion in #7223 |
Reading this as someone who was not aware of this before I saw the issue, this is definitely a footgun for users.
In the meantime, I've added it to Foxtrot and bevy_game_template so that new users of popular templates don't run into this. |
My preference is for more granular control here: being able to enable / disable logs from each crate separately is valuable. I'm also strongly opposed to disabling this by default: this sort of thing should be part of a "preparing for release" documentation IMO. |
I have found this guide very useful and well explained: https://github.com/tbillington/bevy_best_practices?tab=readme-ov-file#release |
While I agree in general, I think it is worth considering that this issue is mainly about Ultimately, I have no strong feelings about what Bevy does or doesn't by default here as long as its well documented. I do think however that it is important that this information is not only part of a release documentation. Such a document would include a lot of things that are not relevant for development like optimizing the binary size or gain performance by taking tradeoffs like longer compile times. As such, I think users will tend to not read that document until they actually want to ship. The addition of Created bevyengine/bevy-website#1510 to track adding this info to the new book. |
Is there an alternative way to achieve the same thing? Because this fails the lint |
For now, I disabled the |
Note that for Wasm builds, the same features need to be enabled for the |
I did some investigation in gfx-rs/wgpu#6046 (comment) and I believe the trace logs could at least be filtered out more efficiently (when the max filter level is below trace) by passing the max level to --- a/crates/bevy_log/src/lib.rs
+++ b/crates/bevy_log/src/lib.rs
@@ -50,7 +50,7 @@ pub use bevy_utils::{
pub use tracing_subscriber;
use bevy_app::{App, Plugin};
-use tracing_log::LogTracer;
+use tracing_log::{AsLog, LogTracer};
#[cfg(feature = "tracing-chrome")]
use tracing_subscriber::fmt::{format::DefaultFields, FormattedFields};
use tracing_subscriber::{
@@ -267,9 +267,11 @@ impl Plugin for LogPlugin {
finished_subscriber = subscriber.with(android_tracing::AndroidLayer::default());
}
- let logger_already_set = LogTracer::init().is_err();
let subscriber_already_set =
bevy_utils::tracing::subscriber::set_global_default(finished_subscriber).is_err();
+ // This must be after setting the global tracing subscriber to get the level hint from it.
+ let max_level_filter = bevy_utils::tracing::level_filters::LevelFilter::current().as_log();
+ let logger_already_set = LogTracer::init_with_filter(max_level_filter).is_err();
match (logger_already_set, subscriber_already_set) {
(true, true) => error!( (inspired by the implementation details of https://docs.rs/tracing-subscriber/0.3.18/tracing_subscriber/util/trait.SubscriberInitExt.html#method.try_init) I looked at |
What problem does this solve or what need does it fill?
Wgpu logs a lot of messages at the trace level. While we filter this out at runtime, the filtering alone is very expensive from the traces we've seen.
bevy/crates/bevy_log/src/lib.rs
Line 163 in a47b91c
What solution would you like?
Use log's cargo features to filter out the trace logs.
E.g.
log = { version = "0.4", features = ["max_level_debug", "release_max_level_warn"] }
.We can make this a bevy-level feature, so that developers wanting to see trace logs or debug logs in release mode could turn this feature off.
What alternative(s) have you considered?
Add a new feature to disable trace logs within the wgpu crate, letting us keep trace logs from our other crates. Wgpu devs are open to this idea gfx-rs/wgpu#5804 (comment).
The text was updated successfully, but these errors were encountered: