Skip to content
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

StaleObjectException #15

Open
janaltenhof opened this issue Jul 13, 2023 · 4 comments
Open

StaleObjectException #15

janaltenhof opened this issue Jul 13, 2023 · 4 comments
Assignees

Comments

@janaltenhof
Copy link

Hi, when I want to run the Baseline Profile Generator in step 7 of the codelab I'm getting this error.
I don't know what to do? Can you help me?

com.google.baselineprofile.BaselineProfileGenerator > generate[pixel6Api31] FAILED 
	androidx.test.uiautomator.StaleObjectException
		at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java:647)
@keyboardsurfer
Copy link
Member

I could not reproduce this locally. Sometimes this happens when the screen turns off during benchmarking. Make sure the display time out is set long enough.

@gerardoeg
Copy link

gerardoeg commented Nov 27, 2023

Please @keyboardsurfer, reactivate this issue, since I'm getting this error over the following run configuration.
Android Studio Iguana | 2023.2.1 Canary 7
AGP = 8.0.0
androidx-baselineprofile = "1.2.0-alpha13"
profileinstaller = "1.3.0"

running task
./gradlew :app:generateReleaseBaselineProfile -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfile --info

SEVERE: Execute com.google.baselineprofile.BaselineProfileGenerator.generate: FAILED
androidx.test.uiautomator.StaleObjectException
        at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java: androidx.test.uiautomator.StaleObjectException
        at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java:647)
        at androidx.test.uiautomator.UiObject2.getVisibleBounds(UiObject2.java:213)
        at androidx.test.uiautomator.UiObject2.getVisibleCenter(UiObject2.java:264)
        at androidx.test.uiautomator.UiObject2.click(UiObject2.java:356)
        at com.google.baselineprofile.BaselineProfileGeneratorKt.goToSnackDetailJourney(BaselineProfileGenerator.kt:87)
        at com.google.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:58)
        at com.google.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:42)
        at androidx.benchmark.macro.BaselineProfilesKt$collectBaselineProfile$1$1.invoke(BaselineProfiles.kt:68)
        at androidx.benchmark.macro.BaselineProfilesKt$collectBaselineProfile$1$1.invoke(BaselineProfiles.kt:62)
        at androidx.benchmark.macro.CompilationMode$Partial.compileImpl$benchmark_macro_release(CompilationMode.kt:319)
        at androidx.benchmark.macro.CompilationMode.resetAndCompile$benchmark_macro_release(CompilationMode.kt:115)
        at androidx.benchmark.macro.BaselineProfilesKt.collectBaselineProfile(BaselineProfiles.kt:62)
        at androidx.benchmark.macro.junit4.BaselineProfileRule.collectBaselineProfile(BaselineProfileRule.kt:131)
        at androidx.benchmark.macro.junit4.BaselineProfileRule.collectBaselineProfile$default(BaselineProfileRule.kt:123)
        at com.google.baselineprofile.BaselineProfileGenerator.generate(BaselineProfileGenerator.kt:42)
androidx.test.uiautomator.StaleObjectException
        at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java:647)
        at androidx.test.uiautomator.UiObject2.getVisibleBounds(UiObject2.java:213)
        at androidx.test.uiautomator.UiObject2.getVisibleCenter(UiObject2.java:264)
        at androidx.test.uiautomator.UiObject2.click(UiObject2.java:356)
        at com.google.baselineprofile.BaselineProfileGeneratorKt.goToSnackDetailJourney(BaselineProfileGenerator.kt:87)
        at com.google.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:58)
        at com.google.baselineprofile.BaselineProfileGenerator$generate$1.invoke(BaselineProfileGenerator.kt:42)
        at androidx.benchmark.macro.BaselineProfilesKt$collectBaselineProfile$1$1.invoke(BaselineProfiles.kt:68)
        at androidx.benchmark.macro.BaselineProfilesKt$collectBaselineProfile$1$1.invoke(BaselineProfiles.kt:62)
        at androidx.benchmark.macro.CompilationMode$Partial.compileImpl$benchmark_macro_release(CompilationMode.kt:319)
        at androidx.benchmark.macro.CompilationMode.resetAndCompile$benchmark_macro_release(CompilationMode.kt:115)
        at androidx.benchmark.macro.BaselineProfilesKt.collectBaselineProfile(BaselineProfiles.kt:62)
        at androidx.benchmark.macro.junit4.BaselineProfileRule.collectBaselineProfile(BaselineProfileRule.kt:131)
        at androidx.benchmark.macro.junit4.BaselineProfileRule.collectBaselineProfile$default(BaselineProfileRule.kt:123)
        at com.google.baselineprofile.BaselineProfileGenerator.generate(BaselineProfileGenerator.kt:42)

@gerardoeg
Copy link

gerardoeg commented Nov 27, 2023

Update @janaltenhof:
By updating the following configuration I made it work.


    testOptions.managedDevices.devices {
        create<ManagedVirtualDevice>("pixel6Api30") {
            device = "Pixel 6"
            apiLevel = 30 // CHANGED FROM 31 TO 30, (32 DIDN'T WORK)
            systemImageSource = "aosp"
        }
    }

Additional note, the following configuration, testing on a physical device using API 34 (Android 14), didn't work.
baselineProfile {
// managedDevices += "pixel6Api30"
useConnectedDevices = true
}

@keyboardsurfer
Copy link
Member

We're working on addressing this within the Macrobenchmark library itself.
In the meantime we recommend running the tests again in case they fail with a StaleObjectException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants