Status Update
Comments
cc...@google.com <cc...@google.com> #2
startActivityAndWait() waits for the first frame, but it's not easy to make it wait for fully drawn, since there's no trivial way to poll - we currently get this info from the trace, which can't be efficiently polled.
Keeping this open as a feature request, there may be a way for us to make this poll-able.
Instead, you'll want to do something like the following after your launch, to check for some item or content showing up with UiAutomator:
check(uiDevice.wait(Until.findObject(By.text(expectedText)), 3000 /*3 sec timeout*/) != null)
You can use methods like
cc...@google.com <cc...@google.com> #3
Over to Rahul, since we talked about what it would take to make this happen. First thing is to see if there's prior art in Hawkeye.
ys...@google.com <ys...@google.com> #4
androidx.activity.compose.ReportDrawnAfter or androidx.activity.ComponentActivity.reportFullyDrawn are potentially interesting hooks.
Is there anything that this could do for the class of Compose apps? You wouldn't need to rely on any new functionality in the platform Activity.
Description
timeToFullDisplayMs metric is missed in report and shown only if delay is added to test.
@Test
public void startup() {
mBenchmarkRule.measureRepeated(
TEST_PACKAGE,
Collections.singletonList(new StartupTimingMetric()),
CompilationMode.DEFAULT,
StartupMode.COLD,
5,
scope -> {
scope.pressHome();
scope.startActivityAndWait();
return Unit.INSTANCE;
});
}
But according to documentation timeToFullDisplayMs should wait reportFullyDrawn() call:
StartupTimingMetric captures app startup timing metrics with these values:
timeToInitialDisplayMs – Time from the system receiving a launch intent until rendering the first frame of the destination Activity.
timeToFullDisplayMs – Time from the system receiving a launch intent until the application reports fully drawn via reportFullyDrawn method. The measurement stops at the completion of rendering the first frame after (or containing) the reportFullyDrawn() call. This measurement may not be available on Android 10 (API level 29) and lower.