Skip to content

test(e2e): stabilise all_files_permission by revoking only while the demo app is stopped - #3761

Open
Fishbowler wants to merge 1 commit into
mainfrom
all-files-permission-revoke-race
Open

Fishbowler wants to merge 1 commit into
mainfrom
all-files-permission-revoke-race

Conversation

@Fishbowler

Copy link
Copy Markdown
Contributor

Why

The all_files_permission e2e flow fails intermittently on Android: after setPermissions revokes all-files access, it lands on the home screen instead of the demo app and can't find "Permission Check". It failed this way in 2 of 19 full-suite runs across API 33–37 (once each on 36 and 37), which stands in the way of moving CI to a newer Android version.

Approach

Android ends an app's process when all-files access is revoked, and does not restart it. The flow revoked access straight after launchApp, which returns before the app has finished starting. Whether the app survived depended on when the revoke landed. Revoking by hand at set delays after am start on API 34:

Revoke after start Result
~0s no kill
0.05s killed, then restarted for the pending launch
0.3s or 2s killed, not restarted: the flow's failure

The section now stops the app, revokes, and reopens it with its own example:// link. It doesn't reopen with launchApp because that applies permissions of its own (all: allow by default) and could mask a broken revoke. Between the revoke and the assertion, only setPermissions and Android touch the permission. Granting doesn't kill the app, so the other sections are unchanged.

Verification

On arm64 emulators configured like CI's (4 cores, 4192 MB, swiftshader, 606×1280), all_files_permission.yaml run alone passed 15/15 on API 34 and 10/10 on API 37, and logcat shows the section no longer kills the app. The old flow also passed 15/15 run alone, because the race is rare, so the table above is the evidence for the cause. Changing the section's revoke to allow makes the flow fail at All Files: Not allowed, so the section still checks the deny.

all_files_permission's setPermissions-deny section revoked all-files
access straight after launchApp, while the app was still starting.
Android ends an app's process when that access is revoked and does not
restart it, so when the revoke landed after startup the flow found the
home screen instead of the app. It failed this way in 2 of 19
full-suite runs across API 33-37, once each on 36 and 37.

Stop the app before revoking, and reopen it with its own example://
link rather than launchApp, which applies permissions of its own and so
could mask a broken revoke.

Run alone, the flow passes 15/15 on API 34 and 10/10 on API 37, and
changing the revoke to allow makes it fail at "All Files: Not allowed".
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

Successfully merging this pull request may close these issues.

1 participant