Bug 1807360 Comment 9 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Hi, :owlish

Under GeckoView Example, basically , it is basically not possible to choose any file to upload.  (for example bug 1591640)

Due to modern Android's security limitation, it is [basically impossible](https://stackoverflow.com/questions/61809732/android-data-does-not-exist-on-getcontentresolver) to get *file path* from [querying "_data" column](https://searchfox.org/mozilla-central/rev/b41bb321fe4bd7d03926083698ac498ebec0accf/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#6341-6350) , so GeckoView will just output a error in the log :  "GeckoSession: Only file URIs are supported:" and do nothing.
Similar discussion happens in bug 1875732

So in fenix part, they did a trick : Copy the content of ContentUri to a *temp file path* that fenix has the control, then return that file path to GeckoView for further handling. The copy operation is very IO heavy especially on large file which mostly cause ANR. This trick have a lot of demerit. for example bug 1856431 (file path's limiation) and bug  1860472 (you need to clean up the temp file path) and bug 1872370 (same filename in different folder)

So I'm here to purpose an alternative way handling file picking. 1) Pass ContentUri from Fenix via GeckoView and directly to Gecko. 2) Gecko open a file descriptor via a JNI call to Android's `ContentResolver.ppenFileDescriptor` API.  3) Do the same operations on this file descriptor as other file descriptors in all platforms.

-----------
File upload is just a further step of file picker. If file picker works, then file upload works. It is the same issue.
Hi, :owlish

Under GeckoView Example, basically , it is basically not possible to choose any file to upload.  (for example bug 1591640 and bug 1515440)

Due to modern Android's security limitation, it is [basically impossible](https://stackoverflow.com/questions/61809732/android-data-does-not-exist-on-getcontentresolver) to get *file path* from [querying "_data" column](https://searchfox.org/mozilla-central/rev/b41bb321fe4bd7d03926083698ac498ebec0accf/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#6341-6350) , so GeckoView will just output a error in the log :  "GeckoSession: Only file URIs are supported:" and do nothing.
Similar discussion happens in bug 1875732

So in fenix part, they did a trick : Copy the content of ContentUri to a *temp file path* that fenix has the control, then return that file path to GeckoView for further handling. The copy operation is very IO heavy especially on large file which mostly cause ANR. This trick have a lot of demerit. for example bug 1856431 (file path's limiation) and bug  1860472 (you need to clean up the temp file path) and bug 1872370 (same filename in different folder)
Reference back to bug 1515440 too.


So I'm here to purpose an alternative way handling file picking. 1) Pass ContentUri from Fenix via GeckoView and directly to Gecko. 2) Gecko open a file descriptor via a JNI call to Android's `ContentResolver.ppenFileDescriptor` API.  3) Do the same operations on this file descriptor as other file descriptors in all platforms.

-----------
File upload is just a further step of file picker. If file picker works, then file upload works. It is the same issue.
Hi, :owlish

Under GeckoView Example, basically , it is basically not possible to choose any file to upload.  (for example bug 1591640 and bug 1515440 and bug 1620301)

Due to modern Android's security limitation, it is [basically impossible](https://stackoverflow.com/questions/61809732/android-data-does-not-exist-on-getcontentresolver) to get *file path* from [querying "_data" column](https://searchfox.org/mozilla-central/rev/b41bb321fe4bd7d03926083698ac498ebec0accf/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#6341-6350) , so GeckoView will just output a error in the log :  "GeckoSession: Only file URIs are supported:" and do nothing.
Similar discussion happens in bug 1875732

So in fenix part, they did a trick : Copy the content of ContentUri to a *temp file path* that fenix has the control, then return that file path to GeckoView for further handling. The copy operation is very IO heavy especially on large file which mostly cause ANR. This trick have a lot of demerit. for example bug 1856431 (file path's limiation) and bug  1860472 (you need to clean up the temp file path) and bug 1872370 (same filename in different folder)
Reference back to bug 1515440 too.


So I'm here to purpose an alternative way handling file picking. 1) Pass ContentUri from Fenix via GeckoView and directly to Gecko. 2) Gecko open a file descriptor via a JNI call to Android's `ContentResolver.ppenFileDescriptor` API.  3) Do the same operations on this file descriptor as other file descriptors in all platforms.

-----------
File upload is just a further step of file picker. If file picker works, then file upload works. It is the same issue.
Hi, :owlish

Under GeckoView Example, basically , it is basically not possible to choose any file to upload.  (for example bug 1591640 and bug 1515440 and bug 1620301)

Due to modern Android's security limitation, it is [basically impossible](https://stackoverflow.com/questions/61809732/android-data-does-not-exist-on-getcontentresolver) to get *file path* from [querying "_data" column](https://searchfox.org/mozilla-central/rev/b41bb321fe4bd7d03926083698ac498ebec0accf/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#6341-6350) , so GeckoView will just output a error in the log :  "GeckoSession: Only file URIs are supported:" and do nothing.
Similar discussion happens in bug 1875732

So in fenix part, they did a trick : Copy the content of ContentUri to a *temp file path* that fenix has the control, then return that file path to GeckoView for further handling. The copy operation is very IO heavy especially on large file which mostly cause ANR. This trick have a lot of demerit. for example bug 1856431 (file path's limiation) and bug  1860472 (you need to clean up the temp file path) and bug 1872370 (same filename in different folder)
Reference back to bug 1515440 too.


So I'm here to purpose an alternative way handling file picking. 1) Pass ContentUri from Fenix via GeckoView and directly to Gecko. 2) Gecko open a file descriptor via a JNI call to Android's `ContentResolver.openFileDescriptor` API.  3) Do the same operations on this file descriptor as other file descriptors in all platforms.

-----------
File upload is just a further step of file picker. If file picker works, then file upload works. It is the same issue.
Hi, :owlish

Under GeckoView Example, it is basically not possible to choose any file to upload.  (for example bug 1591640 and bug 1515440 and bug 1620301)

Due to modern Android's security limitation, it is [basically impossible](https://stackoverflow.com/questions/61809732/android-data-does-not-exist-on-getcontentresolver) to get *file path* from [querying "_data" column](https://searchfox.org/mozilla-central/rev/b41bb321fe4bd7d03926083698ac498ebec0accf/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java#6341-6350) , so GeckoView will just output a error in the log :  "GeckoSession: Only file URIs are supported:" and do nothing.
Similar discussion happens in bug 1875732

So in fenix part, they did a trick : Copy the content of ContentUri to a *temp file path* that fenix has the control, then return that file path to GeckoView for further handling. The copy operation is very IO heavy especially on large file which mostly cause ANR. This trick have a lot of demerit. for example bug 1856431 (file path's limiation) and bug  1860472 (you need to clean up the temp file path) and bug 1872370 (same filename in different folder)
Reference back to bug 1515440 too.


So I'm here to purpose an alternative way handling file picking. 1) Pass ContentUri from Fenix via GeckoView and directly to Gecko. 2) Gecko open a file descriptor via a JNI call to Android's `ContentResolver.openFileDescriptor` API.  3) Do the same operations on this file descriptor as other file descriptors in all platforms.

-----------
File upload is just a further step of file picker. If file picker works, then file upload works. It is the same issue.

Back to Bug 1807360 Comment 9