Comments (18)
This sounds like it would be a good sample then! I can do this
from performance-samples.
Are you after a sample that would show Composable functions in a macrobenchmark trace? I think if we just add the dependency to the macrobenchmark sample, it should work.
from performance-samples.
All the issues with versions and compatibility issues should be resolved by now by using latest versions of the libraries.
I also added a sample on how to setup composition tracing in this sample #263.
Thanks for the report!
from performance-samples.
Passing this over to @bentrengrove for evaluation.
from performance-samples.
You also need to enable the flag that turns on composition tracing: https://developer.android.com/topic/performance/benchmarking/macrobenchmark-instrumentation-args#fulltracing
This is off by default for now since it doesn't support tracing during cold startups (which is being worked on), and because overhead was a concern (though several optimizations have landed since).
from performance-samples.
Perfect. It mostly that.
But also a forcing function to see a proper project setup with the dependencies and proguard rules.
from performance-samples.
Contrary to https://developer.android.com/jetpack/compose/tooling/tracing
I don't think you need these in your app as a implementation dependency.
https://github.com/google/horologist/pull/1209/files
add("benchmarkImplementation", libs.androidx.tracing.perfetto)
add("benchmarkImplementation", libs.androidx.tracing.perfetto.binary)
from performance-samples.
This was a nice win of the composition tracing, showing composition counts
MarqueeBenchmark_noMarquee
CanvasRecomposeCount min 55.0, median 55.0, max 55.0
CanvasRecomposeDurMs min 8.3, median 8.3, max 8.3
from performance-samples.
@bentrengrove Any updates on adding composition tracing example? I tried adding the dependencies and enabled the required flags as per the documentation, but it is not working.
@yschimke I have added those perfetto tracing dependencies benchmarkImplementation
, but the app is crashing as soon as opened. Did you face something similar? I don't have a watch to run those benchmarks, so tried to use the same setup on phone with nowinandroid
app.
from performance-samples.
What is the stacktrace?
from performance-samples.
What is the stacktrace?
@yschimke Here's the stacktrace:
FATAL EXCEPTION: main
Process: com.google.samples.apps.nowinandroid.demo.benchmark, PID: 20835
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/tracing/perfetto/Tracing;
at androidx.compose.runtime.tracing.TracingInitializer$create$1.isTraceInProgress(Unknown Source:0)
at coil.util.-Contexts.isTraceInProgress(SourceFile:1)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(SourceFile:3)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(SourceFile:1)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(SourceFile:7)
at okhttp3.CertificatePinner$check$1.invoke(SourceFile:92)
at okhttp3.CertificatePinner$check$1.invoke(SourceFile:8)
at okio.Utf8.observeDerivedStateRecalculations(SourceFile:43)
at androidx.compose.runtime.ComposerImpl.doCompose(SourceFile:129)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(SourceFile:1)
at androidx.compose.runtime.CompositionImpl.composeContent(SourceFile:19)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(SourceFile:39)
at androidx.compose.runtime.CompositionImpl.setContent(Unknown Source:10)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(SourceFile:11)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(Unknown Source:11)
at androidx.compose.ui.platform.WrappedComposition.setContent(Unknown Source:13)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Unknown Source:18)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(SourceFile:23)
at androidx.lifecycle.LifecycleRegistry.addObserver(SourceFile:107)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(SourceFile:11)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(SourceFile:119)
at android.view.View.dispatchAttachedToWindow(View.java:20018)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3589)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2208)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1873)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8496)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:986)
at android.view.Choreographer.doCallbacks(Choreographer.java:764)
at android.view.Choreographer.doFrame(Choreographer.java:699)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:965)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.tracing.perfetto.Tracing" on path: DexPathList[[zip file "/data/app/com.google.samples.apps.nowinandroid.demo.benchmark-nAbe9X37TJQHd9EsCgdfyw==/base.apk"],nativeLibraryDirectories=[/data/app/com.google.samples.apps.nowinandroid.demo.benchmark-nAbe9X37TJQHd9EsCgdfyw==/lib/arm64, /data/app/com.google.samples.apps.nowinandroid.demo.benchmark-nAbe9X37TJQHd9EsCgdfyw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at androidx.compose.runtime.tracing.TracingInitializer$create$1.isTraceInProgress(Unknown Source:0)
at coil.util.-Contexts.isTraceInProgress(SourceFile:1)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(SourceFile:3)
at androidx.compose.ui.platform.WrappedComposition$setContent$1$1.invoke(SourceFile:1)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(SourceFile:7)
at okhttp3.CertificatePinner$check$1.invoke(SourceFile:92)
at okhttp3.CertificatePinner$check$1.invoke(SourceFile:8)
at okio.Utf8.observeDerivedStateRecalculations(SourceFile:43)
at androidx.compose.runtime.ComposerImpl.doCompose(SourceFile:129)
at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(SourceFile:1)
at androidx.compose.runtime.CompositionImpl.composeContent(SourceFile:19)
at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(SourceFile:39)
at androidx.compose.runtime.CompositionImpl.setContent(Unknown Source:10)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(SourceFile:11)
at androidx.compose.ui.platform.AndroidComposeView.setOnViewTreeOwnersAvailable(Unknown Source:11)
at androidx.compose.ui.platform.WrappedComposition.setContent(Unknown Source:13)
at androidx.compose.ui.platform.WrappedComposition.onStateChanged(Unknown Source:18)
at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(SourceFile:23)
at androidx.lifecycle.LifecycleRegistry.addObserver(SourceFile:107)
at androidx.compose.ui.platform.WrappedComposition$setContent$1.invoke(SourceFile:11)
at androidx.compose.ui.platform.AndroidComposeView.onAttachedToWindow(SourceFile:119)
at android.view.View.dispatchAttachedToWindow(View.java:20018)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3589)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3596)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2208)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1873)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8496)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:986)
at android.view.Choreographer.doCallbacks(Choreographer.java:764)
at android.view.Choreographer.doFrame(Choreographer.java:699)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:965)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
I have done the set up similar to the horologist project which seems to be contrary to what the documentation says about adding the tracing dependencies. Shouldn't they be added into Macrobenchmark module and not in the app module? Here's my branch if you want to try it out.
from performance-samples.
I think the docs are wrong. I've added it to the app module and it works.
The section above for capturing for the command line also says add to the app. https://developer.android.com/jetpack/compose/tooling/tracing#terminal
from performance-samples.
Now it's really confusing. I added in the app module and it fails with the error mentioned above. I wanted to explore the Compose traces from Macrobenchmark tests and having a sample for apps would surely help here. Not to mention that having a single source of truth would benefit everyone!
I have created a separate issue in horologist to reduce unnecessary noise here.
from performance-samples.
Hm, this is what eng for tracing recommended doing for Macrobenchmark.
Could you pls mention the details in https://issuetracker.google.com/issues/286228781
from performance-samples.
Yes, I tried the recommended approach as well and still it is not working. Maybe something is in the documentation?
from performance-samples.
It's temporarily broken with some workarounds https://issuetracker.google.com/issues/286228781
And I need to update the Horologist samples after this lands tomorrow.
from performance-samples.
@mlykotom should this be closed? I'd expect a gradle file with androidx.benchmark.fullTracing.enable
.
from performance-samples.
I haven't added this to the gradle file as some benchmarks might not work properly.
Instead, I added a run configuration that is stored within the project, which uses the argument
https://github.com/android/performance-samples/pull/263/files#diff-49f04f884293f57bf255ab94f217650ec55ac63317df696b314826a3a5bd056dR10
from performance-samples.
Related Issues (20)
- jankFrameListener run 2 times for onCreate HOT 5
- How can you pull the baseline profile in CI? HOT 3
- Getting Could not find com.squareup.okio:okio-bom:2.8.0. HOT 1
- TestRunner: java.lang.IllegalStateException: Perfetto tracing failed to start. HOT 1
- Does matchingFallbacks work if libraries are imported via releaseImplementation and debugImplementation? HOT 2
- Samples doesn't work for dynamic feature modules HOT 4
- Does Baseline Profile just helps with very First launch HOT 1
- [JankStat] [Feature] Provide expectedDuration of Frame in FramaData HOT 1
- java.io.FileNotFoundException - perfetto-trace HOT 2
- Fix GitHub build for macrobenchmark sample
- A question about just one baseline-prof.txt(PR : #258) HOT 4
- Question about the difference in file size inside the aab depending on the location of the generated baseline-prof.txt file
- Fix the GitHub Actions build by not executing benchmarks on an emulator
- Failing to run assembleDebugAndroidTest in MacrobenchmarkSample app
- Why macrobenchmark module's build.gradle has "isDebuggable = true" HOT 1
- Failing tests in the Macrobenchmark sample
- Where and with what name to store the multiple profile HOT 7
- Can only fetch a single baseline profile from Firebase Test Lab
- Add sample for Custom (Async) Trace and TraceMetric
- java.io.FileNotFoundException: http://localhost:9001/status - PerfettoHttpServer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from performance-samples.