[BUG] [Andriod][FileSaver] Crash when removing USB drive
Is there an existing issue for this?
- [X] I have searched the existing issues
Did you read the "Reporting a bug" section on Contributing file?
- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug
Current Behavior
Crash when removing USB drive in Android7.1 after save a file. No Exception was throw.
Expected Behavior
File save Normally
Steps To Reproduce
- Open Toolkit\ Toolkit.sln
- Click 'FileSaver' to save a file to USB drive
- remove USB drive
Link to public reproduction project repository
https://github.com/BaY1251/MauiDebug.git
Environment
- .NET MAUI CommunityToolkit:7.0.0
- OS:Android7.1
- .NET MAUI:8.0
Anything else?
adb log here "app died" in line 454 file.log
another Bug is report "Unable to resolve absolute path where the file was saved 'content://com.android.providers.downloads.documents/document/66'", when save to the Internal storage.
I'm struggling to follow when the error exactly occurs. Are you removing the USB stick during the save? Looking at your GIF the file only reaches 0KB when the dialog disappears but there should be some content.
@bijington Not really! From Gif, it appears that the 'SaveAsync' method has returned and IsSuccessful==true! Besides, I even tried to wait for ten minutes before unplugging the USB drive
AND, The file is normal and can be viewed
@BaY1251 thanks for the clarification
Hi @BaY1251. We have added the "needs reproduction" label to this issue, which indicates that we cannot take further action. This issue will be closed automatically in 5 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I wrote the wrong solution name,Sorry for the mistake.
it is Toolkit\ Toolkit.sln.
I will create a PR #1746, for this issue
This issue may need to be reopened, #1751 is invalid for #1588
I am not to reproduce the issue after the fix.
From docs: An OutputStream you can create on a ParcelFileDescriptor, which will take care of calling ParcelFileDescriptor#close ParcelFileDescriptor.close() for you when the stream is closed.
Stream is closed on Dispose.
Dispose() did not close the file.
On screenshot you provide, Dispose is not called yet
The first image shows FD closing after calling Close. The second image shows that FD is still open after calling Dispose.
I am unable to view the source code of AutoCloseOutputStream. If you can see the source code, it would be best to confirm that
Stream is closed on Dispose
I confirm that AutoCloseOutputStream is invalid for all my existing devices. You'd better test a few more Android devices and USB drives.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
复现问题的log和相关截屏我已经都提交了,#1751并没有解决问题,也没有改变log. 如果没有更多的人能复现这个问题,那这个问题应该就不是问题.可能大概只是我的问题吧.
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 3 days. It will be closed if no further activity occurs within 2 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.
We haven't received a reproduction sample from you. The issue is closed.