-
Notifications
You must be signed in to change notification settings - Fork 505
[Bug] FilePicker stopped working on Android #1538
Comments
This might have been introduced here: #1446 @dimonovdd @IngweLand what file is this? A local file? A virtual (on google drive) file? I don't remember getting the error at all, so this is something new. |
I also have the feeling that it was introduced in #1446 |
OK, it seems that the issue is project specific. I have just created a minimal sample app with latest Essentials, and can select the file on that same device. Will investigate, what's so specific with my app why it stopped working there. |
Here is the simple code to reproduce the issue. The reason is in that delay. Everything works when it's extremally short (<50 millis). However, it starts failing when the delay is >100 millis. In my app, I have to introduce that delay purely as a hack, so the loading bar have time to appear (selecting big files blocks the UI completely, even though it has an async API).
|
I have managed to restructure my app and got it working. Not sure if this still should be considered a bug or not. It does not feel right that the file access got invalid just in 100 milliseconds. Although, this might be expected. |
I tested this with delay(1000), and it works correctly |
I was thinking that maybe it might not work with the fact we are no longer using persisted uris, but it only resets after a reboot. @IngweLand, are you able to test on another device or even another emulator? I tested on a Pixel 2 and a Razer Phone without issues. |
I will try to test on another device/emulator. Currently, my setup is: The workaround, which worked for me, was to get the reference to that stream right away, and then use the delay for a UI hack. |
This is interesting as the fact that the item is in the manifest means that it should keep the code. The manifest doesn't get linked, then the manifest references the class, which preserves it. Maybe something changed in the linker that now links first before adding it to the manifest... I'll check with the Android team. |
Checked with another device, and it worked with delay there: Target SDK - Android 11 |
@dimonovdd what device were you testing on? I hope this is not an issue with a specific device... |
@mattleibow |
Maybe this is due to some GC operation collecting something which in turn invalidates a file? Try adding a GC.Collect() before reading it. |
Based on that post, it looks like it is getting cleanup up. @IngweLand if you open a stream, and then delay for a long time, does it still work? We might be able to do the same trick we do with iOS and open the stream, and then pass that to the result object: |
@IngweLand can you submit a sample project that reproduce this issue? |
The sample project would be very basic:
On a side note. While my concrete use case (with that delay for UI hack) is not a common one, I can imagine more valid general scenario.
|
I think I know what is happening. We use an intermediate activity for launching the picker. This makes sure that you don't have to worry about callbacks. However, it turns out that once the intermediate activity finishes, then the file that was picked is cleaned up. This is why when you open it really quickly, it works, but the delay fails. I am looking at what we can do, and I think I have an idea that I am trying out now. |
I answered my own question. This also happens with the |
Description
Selecting any file on Android does not work.
Steps to Reproduce
await fileData.OpenReadAsync()
Expected Behavior
Should be able to pick the file
Actual Behavior
Cannot pick the file
Basic Information
Version with issue: 1.6.0-pre4
Last known good version: 1.6.0-pre3
IDE: VS 2019 16.8.0
Platform Target Frameworks:
Affected Devices: Pixel3a, Android 11
Workaround
Downgrade to 1.6.0-pre3
The text was updated successfully, but these errors were encountered: