Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Errors in creating and maintaining UiAutomation connection in Instrumented tests #25132

Closed
AaronMT opened this issue May 5, 2022 · 15 comments
Closed
Assignees
Labels
eng:ui-test UI Tests needs:triage Issue needs triage

Comments

@AaronMT
Copy link
Contributor

AaronMT commented May 5, 2022

Intermittently, an early getInstrumentation() call in beforeActivityLaunched for our HomeActivityTestRule.kt will throw a java.lang.RuntimeException with a Error while connecting UiAutomation. This seems to happen more frequent on 1.4.0 and espresso 3.4.0 libraries [2] - just getting a ticket on file here to wrap this call and try again (although I don't know if multiple attempts to get a handle on the running instrumentation will do anything). This is for executing a shell command to set a timeout on long tap.

Stack:

java.lang.RuntimeException: Error while connecting UiAutomation@afc456f[id=-1, flags=0]
at android.app.UiAutomation.connect(UiAutomation.java:259)
at android.app.Instrumentation.getUiAutomation(Instrumentation.java:2176)
at androidx.test.uiautomator.UiDevice.getUiAutomation(UiDevice.java:1129)
at androidx.test.uiautomator.QueryController.<init>(QueryController.java:95)
at androidx.test.uiautomator.UiDevice.<init>(UiDevice.java:109)
at androidx.test.uiautomator.UiDevice.getInstance(UiDevice.java:261)
at org.mozilla.fenix.helpers.HomeActivityTestRuleKt.setLongTapTimeout(HomeActivityTestRule.kt:78)

[1] Firebase Log
[2] Ticket filed as android/android-test#1305

┆Issue is synchronized with this Jira Task

@AaronMT AaronMT added the eng:ui-test UI Tests label May 5, 2022
@AaronMT AaronMT self-assigned this May 5, 2022
@github-actions github-actions bot added the needs:triage Issue needs triage label May 5, 2022
AaronMT added a commit to AaronMT/fenix that referenced this issue May 5, 2022
AaronMT added a commit to AaronMT/fenix that referenced this issue May 5, 2022
…ly getInstrumentation() call

fix: ktlint
@AndiAJ
Copy link
Collaborator

AndiAJ commented May 6, 2022

Corresponding intermitent tests:
customTabShareTextTest #25099
privateBrowsingUseAppWhileTabIsCrashedTest #25076
verifyExpandedCollectionItemsTest #25075
verifyContextOpenImageNewTab #25054

mergify bot pushed a commit that referenced this issue May 10, 2022
@AndiAJ
Copy link
Collaborator

AndiAJ commented May 23, 2022

Hey @AaronMT , it's still happening.
closeAllTabsTest #25341
openMainMenuSettingsItemTest #25342

@sv-ohorvath
Copy link
Contributor

New cases started to appear:
saveLoginFromPromptTest #25414
addPrivateBrowsingShortcut #25416
customTabsOpenExternalLinkTest #25028
downloadMultipleFileTypesTest #25296

@AaronMT
Copy link
Contributor Author

AaronMT commented Jun 1, 2022

I filed an issue on a Google issue tracker, I have no idea what causes this. I suspect it's a particular in androidx.test.uiautomator:uiautomator

https://issuetracker.google.com/u/1/issues/233914320

@sv-ohorvath
Copy link
Contributor

java.lang.IllegalStateException: UiAutomation not connected, UiAutomation in the following issues:
https://github.com/mozilla-mobile/fenix/issues?q=is%3Aissue+is%3Aopen+java.lang.IllegalStateException%3A+UiAutomation+not+connected%2C+UiAutomation

@AaronMT AaronMT changed the title Wrap early beforeActivityLaunched getInstrumentation() call in Try/Catch Errors in creating and maintaining UiAutomation connection in Instrumented tests Jun 17, 2022
@AaronMT
Copy link
Contributor Author

AaronMT commented Jun 30, 2022

FTL team responded back on Slack that a potential fix should be in as of yesterday (06/29), let's keep a track on any reoccurrence and I'll reply back.

@AndiAJ
Copy link
Collaborator

AndiAJ commented Jul 1, 2022

► 6/30

java.lang.IllegalStateException: UiAutomation not connected, UiAutomation
searchSettingsItemsTest

java.lang.RuntimeException: Error while connecting UiAutomation
verifyMultipleLoginsSelectionsTest
mainMenuShareButtonTest
closePrivateTabTest
emptyTabsTrayViewPrivateBrowsingTest
openMainMenuAddToCollectionTest

@AndiAJ
Copy link
Collaborator

AndiAJ commented Jul 4, 2022

► 7/4

java.lang.RuntimeException: Error while connecting UiAutomation
deleteTabsDataWithNoOpenTabsTest

@AndiAJ
Copy link
Collaborator

AndiAJ commented Jul 5, 2022

► 7/5

java.lang.IllegalStateException: UiAutomation not connected, UiAutomation
navigateBookmarksFoldersTest
emailLinkPWATest

@AaronMT
Copy link
Contributor Author

AaronMT commented Jul 5, 2022

Firebase Team Update:

Hello Aaron,
Thank you for your patience while this issue was troubleshooted.
The product team have narrowed down the issue to GmsCore, which is encountering issues with virtual images.
An update is scheduled sometime in the next few weeks which should address this issue.
Until the update is rolled out, the Test Lab team suggests that we should monitor the public issue [1].
Please let me know if you have any further questions regarding this issue.
Thank you

[1] https://issuetracker.google.com/issues/233914320

Also in communication with a member on the Firebase Community Slack about a fix too.

@AndiAJ
Copy link
Collaborator

AndiAJ commented Jul 6, 2022

► 7/5

java.lang.IllegalStateException: UiAutomation not connected, UiAutomation
deleteHistoryItemTest
multipleBookmarkDeletionsTest
editBookmarkTest

java.lang.RuntimeException: Error while connecting UiAutomation
verifyAddToFirefoxHome
verifyUndoSnackBarTest
openLinkInAppTest
testCloseDownloadPrompt
testDownloadCompleteNotification
editBookmarkTest

@Mugurell
Copy link
Contributor

Mugurell commented Aug 3, 2022

Saw the issue again in #26299 for verifyEmptyTabTray.

@AaronMT
Copy link
Contributor Author

AaronMT commented Aug 8, 2022

Currently waiting on Google to push out an update to Firebase Test Lab to ensure all devices are using newer GMSCore (FLOSS Play Services) version which was the culprit of this problem. Currently in test runs, some devices are on the newer Play Services version (you can tell from the first frame in videos) and some are using the older version which is another bug.

@AaronMT
Copy link
Contributor Author

AaronMT commented Sep 15, 2022

FTL Update (09.15)

The fix has finally been pushed to production. The issue should be resolved now, please give it a try.

We've also switched to Pixel2.arm (ARM) running a new GMSCore (Play Services), and have knock on wood yet to see see too. We can re-enable the affected tests and close this out.

@AaronMT
Copy link
Contributor Author

AaronMT commented Oct 19, 2022

This was resolved on their end.

@AaronMT AaronMT closed this as completed Oct 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
eng:ui-test UI Tests needs:triage Issue needs triage
Projects
None yet
Development

No branches or pull requests

4 participants