Skip to content

Commit 173c352

Browse files
authored
enable tracy subscriber layer on android (bevyengine#21760)
# Objective I really need tracing on android right now as I'm attempting to profile bevy running on a quest 3. ## Solution I saw [this issue](bevyengine#21612) already opened about it around 2 weeks ago, and I was able to use it to figure out how to enable tracy to run on android. However I did not enable it for IOS and made sure to retain the same behavior for other flags such as chrome style profiling. ## Testing I've tested that the engine still builds on both windows and to android. Additionally the flame graph will now show complete frames of info, instead of one single mono-frame with 4 different render events. Android also requires: `android.permission.INTERNET` and possibly `android.permission.NEARBY_WIFI_DEVICES` to be able to host the debug server. ## Showcase Tracy running for an apk deployed to a quest 3. <img width="2090" height="687" alt="image" src="https://github.com/user-attachments/assets/16e249c4-48db-46fd-baa0-604ec9a12856" />
1 parent 0b802bd commit 173c352

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

crates/bevy_log/src/lib.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,9 @@ impl Plugin for LogPlugin {
336336
#[cfg(feature = "trace")]
337337
let subscriber = subscriber.with(tracing_error::ErrorLayer::default());
338338

339-
#[cfg(all(
340-
not(target_arch = "wasm32"),
341-
not(target_os = "android"),
342-
not(target_os = "ios")
343-
))]
339+
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "ios")))]
344340
{
345-
#[cfg(feature = "tracing-chrome")]
341+
#[cfg(all(feature = "tracing-chrome", not(target_os = "android")))]
346342
let chrome_layer = {
347343
let mut layer = tracing_chrome::ChromeLayerBuilder::new();
348344
if let Ok(path) = std::env::var("TRACE_CHROME") {
@@ -386,10 +382,12 @@ impl Plugin for LogPlugin {
386382

387383
let subscriber = subscriber.with(fmt_layer);
388384

389-
#[cfg(feature = "tracing-chrome")]
385+
#[cfg(all(feature = "tracing-chrome", not(target_os = "android")))]
390386
let subscriber = subscriber.with(chrome_layer);
391387
#[cfg(feature = "tracing-tracy")]
392388
let subscriber = subscriber.with(tracy_layer);
389+
#[cfg(target_os = "android")]
390+
let subscriber = subscriber.with(android_tracing::AndroidLayer::default());
393391
finished_subscriber = subscriber;
394392
}
395393

@@ -400,11 +398,6 @@ impl Plugin for LogPlugin {
400398
));
401399
}
402400

403-
#[cfg(target_os = "android")]
404-
{
405-
finished_subscriber = subscriber.with(android_tracing::AndroidLayer::default());
406-
}
407-
408401
#[cfg(target_os = "ios")]
409402
{
410403
finished_subscriber = subscriber.with(tracing_oslog::OsLogger::default());

0 commit comments

Comments
 (0)