Open Bug 1840443 Opened 1 year ago Updated 27 days ago

geckodriver fails with "adb error: fchown failed: Operation not permitted" on Android 11 and later

Categories

(Testing :: geckodriver, defect, P2)

Default
defect

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned, NeedInfo)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [webdriver:backlog])

Reported via: https://github.com/mozilla/geckodriver/issues/1885#issuecomment-1600259567

Using Android 11 and later geckodriver fails to setup the profile for Firefox and as such bails out early without allowing to run any tests. Here the log file as produced by geckodriver:

1687794900082	mozdevice	TRACE	execute_host_command: >> "shell:ls /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root"
1687794900096	mozdevice	TRACE	execute_host_command: << ""
1687794900096	mozdevice	DEBUG	Creating /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root/org.mozilla.geckoview.test_runner-geckodriver-profile
1687794900097	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900099	mozdevice	TRACE	execute_host_command: << []
1687794900099	mozdevice	TRACE	execute_host_command: >> "shell:mkdir -p /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root/org.mozilla.geckoview.test_runner-geckodriver-profile"
1687794900118	mozdevice	TRACE	execute_host_command: << ""
1687794900118	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900119	mozdevice	TRACE	execute_host_command: << []
1687794900119	mozdevice	TRACE	execute_host_command: >> "shell:chmod  -R 777 /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root/org.mozilla.geckoview.test_runner-geckodriver-profile"
1687794900133	mozdevice	TRACE	execute_host_command: << ""
1687794900139	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900139	mozdevice	TRACE	execute_host_command: << []
1687794900139	mozdevice	TRACE	execute_host_command: >> "shell:am clear-debug-app org.mozilla.geckoview.test_runner"
1687794900182	mozdevice	TRACE	execute_host_command: << ""
1687794900182	geckodriver::android	DEBUG	Disabled reading from configuration file
1687794900182	mozdevice	DEBUG	Deleting /data/local/tmp/org.mozilla.geckoview.test_runner-geckoview-config.yaml
1687794900183	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900183	mozdevice	TRACE	execute_host_command: << []
1687794900183	mozdevice	TRACE	execute_host_command: >> "shell:rm -rf /data/local/tmp/org.mozilla.geckoview.test_runner-geckoview-config.yaml"
1687794900214	mozdevice	TRACE	execute_host_command: << ""
1687794900214	geckodriver::android	DEBUG	Deleted GeckoView configuration file
1687794900214	mozdevice	DEBUG	Deleting /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root
1687794900216	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900216	mozdevice	TRACE	execute_host_command: << []
1687794900216	mozdevice	TRACE	execute_host_command: >> "shell:rm -rf /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root"
1687794900253	mozdevice	TRACE	execute_host_command: << ""
1687794900254	geckodriver::android	DEBUG	Deleted test root folder: /sdcard/Android/data/org.mozilla.geckoview.test_runner/files/test_root
1687794900255	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900255	mozdevice	TRACE	execute_host_command: << []
1687794900255	mozdevice	TRACE	execute_host_command: >> "host-serial:25051FDF6006PA:killforward:tcp:53811"
1687794900255	mozdevice	TRACE	execute_host_command: << ""
1687794900255	geckodriver::android	DEBUG	Marionette port forward (53811 -> 2829) stopped
1687794900256	mozdevice	TRACE	execute_host_command: >> "host:transport:25051FDF6006PA"
1687794900256	mozdevice	TRACE	execute_host_command: << []
1687794900256	mozdevice	TRACE	execute_host_command: >> "host-serial:25051FDF6006PA:killforward:tcp:9222"
1687794900256	mozdevice	TRACE	execute_host_command: << ""
1687794900256	geckodriver::android	DEBUG	WebSocket port forward (9222 -> 9222) stopped
1687794900256	webdriver::server	DEBUG	<- 500 Internal Server Error {"value":{"error":"unknown error","message":"adb error: fchown failed: Operation not permitted","stacktrace":""}}
DEBUG:urllib3.connectionpool:http://localhost:4444 "POST /session HTTP/1.1" 500 113
DEBUG:root:response: {'value': {'error': 'unknown error', 'message': 'adb error: fchown failed: Operation not permitted', 'stacktrace': ''}}
Traceback (most recent call last):

The documentation for the changes can be found at:
https://developer.android.com/about/versions/11/privacy/storage

Maybe we could set the requestLegacyExternalStorage to true for now in the manifest file to keep it working as for Android 10.

I can actually see this problem with a Pixel 6.

Actually I can workaround this problem by using --android-storage=app but then geckodriver fails to start the test_runner package. Interesting is that app doesn't seem to work for others.

Priority: -- → P2
Whiteboard: [webdriver:backlog]

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hskupin)

While this is a geckodriver issue and not resolved, I just wanted to add for future readers were also able to use the fix of using --android-storage=app to our performance testing code(done in bug 1857623) and this issue is no longer occurring in CI for us on the Pixel 6 devices.

Blocks: 1700559
You need to log in before you can comment on or make changes to this bug.