Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[BUG] [Andriod][FileSaver] Crash when removing USB drive

Open BaY1251 opened this issue 2 years ago • 12 comments

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

  1. Open Toolkit\ Toolkit.sln
  2. Click 'FileSaver' to save a file to USB drive
  3. 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?

FileSaver

adb log here "app died" in line 454 file.log

BaY1251 avatar Dec 04 '23 07:12 BaY1251

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.

BaY1251 avatar Dec 04 '23 07:12 BaY1251

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 avatar Dec 04 '23 19:12 bijington

@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

BaY1251 avatar Dec 05 '23 00:12 BaY1251

AND, The file is normal and can be viewed

file

BaY1251 avatar Dec 05 '23 00:12 BaY1251

@BaY1251 thanks for the clarification

bijington avatar Dec 10 '23 20:12 bijington

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.

ghost avatar Mar 11 '24 22:03 ghost

I wrote the wrong solution name,Sorry for the mistake. it is Toolkit\ Toolkit.sln.

BaY1251 avatar Mar 12 '24 06:03 BaY1251

I will create a PR #1746, for this issue

BaY1251 avatar Mar 12 '24 09:03 BaY1251

This issue may need to be reopened, #1751 is invalid for #1588

BaY1251 avatar Mar 14 '24 01:03 BaY1251

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.

VladislavAntonyuk avatar Mar 14 '24 05:03 VladislavAntonyuk

Dispose() did not close the file.

Close Dispose

BaY1251 avatar Mar 14 '24 06:03 BaY1251

On screenshot you provide, Dispose is not called yet

VladislavAntonyuk avatar Mar 14 '24 13:03 VladislavAntonyuk

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.

BaY1251 avatar Mar 15 '24 01:03 BaY1251

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. 如果没有更多的人能复现这个问题,那这个问题应该就不是问题.可能大概只是我的问题吧.

BaY1251 avatar Apr 06 '24 11:04 BaY1251

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.