Open jus4ru opened 2 years ago
I first got an exception like this one by trying to move (cut & paste) 31944 files from internal storage to the SD card.
Then I was able to move 31944 files from one directory in internal storage to another, empty one, also in the internal storage. So Amaze can move 31944 files in one shot.
After that I got an exception like this one trying to move those same 31944 files from the new internal storage directory to an empty directory in the SD card. I tried with two different target directories to see if there was something about file paths' length, but the data parcel
size in the exception was the same for both cases - so it doesn't seem to have to do with file names.
I can test any other scenarios you may come up with, if that's useful.
I've spent a while taking a look at this issue.
Android's Binder
defines a hard-coded limit of 1MB for IPC transaction buffers (or something like that). (source: https://developer.android.com/reference/android/os/TransactionTooLargeException)
We're trying to start an Intent
with the list of files to move/copy, and - with ~30k paths - it's easy to hit 1MB (1MB / 30k ~= 35 bytes per path object).
Intent
a pointer to that thing. This would be the preferred way, since we would completly avoid the issue with a not-that-big change.Parcelable
ArrayList
of paths (or the whole Intent
) before starting the Intent and maybe abort the operation if it's not below 1MB.
[ "/path/to/file1.bin", "/path/to/file2.bin"]
, change it to /path/to
& ["file1.bin", "file2.bin"]
). This would work on most cases, except on Recent
views and similar, in which user could select files on different directories at the same time.Intent
seems to be created anyways.The byte size of an Intent
object can be obtained by this piece of code:
Intent intent = new Intent(context.get(), CopyService.class);
// ... set stuff on intent ...
Parcel parcel = Parcel.obtain();
parcel.writeParcelable(intent, 0);
Log.e("The intent lenght is " + parcel.dataSize() + " bytes");
Issue explanation (write below this line)
I'm getting a considerable amount of app breaking errors stemming from SD card usage.
Exception
Crash log