Skip to content

Add logging/tracing support #1

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

Merged
merged 1 commit into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 174 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ parley = { git = "https://github.com/linebender/parley", features = ["accesskit"
peniko = { version = "0.3.1", default-features = false }
pollster = "0.4.0"
vello = "0.4.0"

# Send tracing events to Android GPU inspector, for profiling
tracing_android_trace = "0.1.1"
tracing-subscriber = "0.3.19"
# Make events recorded with profiling (e.g. in wgpu) visible to Android GPU inspector
profiling = { version = "1.0.16", features = ["profile-with-tracing"] }
# Make events recorded to `tracing` visible in logcat
tracing = { version = "0.1.38", features = ["log-always"] }
8 changes: 8 additions & 0 deletions demo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use log::LevelFilter;
use std::ffi::c_void;
use std::num::NonZeroUsize;
use std::time::Instant;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use vello::kurbo;
use vello::peniko::Color;
use vello::util::{RenderContext, RenderSurface};
Expand Down Expand Up @@ -525,6 +526,13 @@ pub unsafe extern "system" fn JNI_OnLoad(vm: *mut RawJavaVM, _: *mut c_void) ->
.with_max_level(LevelFilter::Trace)
.with_tag("android-view-demo"),
);
// This will try to create a "log" logger, and error because one was already created above
// We therefore ignore the error
// Ideally, we'd only ignore the SetLoggerError, but the only way that's possible is to inspect
// `Debug/Display` on the TryInitError, which is awful.
let _ = tracing_subscriber::registry()
.with(tracing_android_trace::AndroidTraceLayer::new())
.try_init();

let vm = unsafe { JavaVM::from_raw(vm) }.unwrap();
let mut env = vm.get_env().unwrap();
Expand Down