OxygenCobalt / Auxio

A simple, rational music player for android
GNU General Public License v3.0
2.18k stars 147 forks source link

Crash after importing any M3U file through 3rd party file manager #700

Open Thoerix opened 9 months ago

Thoerix commented 9 months ago

Describe the Bug/Crash

After launching the app, go to the playlist tab and try to import a playlist. The native file manager will open. Click on the hamburger icon and select any 3rd party file manager. Selecting any M3U file from there will instantly crash Auxio ( Weirdly, GDrive is an exception - Auxio just refuses to load anything from it and toasts "Unable to import a playlist from this file." message )

Might be related to #693 and #673

Describe the intended behavior

It should load it. Tested on two other devices and the result is the same

What android version do you use?

Android 13

What device model do you use?

Xiaomi POCO F3

Bug report

java.lang.IllegalArgumentException: Invalid URI: content://media/external/file/1000014949 at android.provider.DocumentsContract.getDocumentId(DocumentsContract.java:1278) at org.oxycblt.auxio.music.fs.DocumentPathFactoryImpl.unpackDocumentUri(SourceFile:6) at org.oxycblt.auxio.music.MusicViewModel$importPlaylist$1.invokeSuspend(SourceFile:50) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8) at kotlinx.coroutines.DispatchedTask.run(Unknown Source:94) at androidx.fragment.app.Fragment$4.run(SourceFile:43) at kotlinx.coroutines.scheduling.TaskImpl.run(Unknown Source:2) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(SourceFile:92) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@7ee72c4, Dispatchers.IO]

Sometimes the URI is different, depending on the file manager. It can look something like this: java.lang.IllegalArgumentException: Invalid URI: content://{file manager's package name}/file/{URL encoded path to the file, starting with :///storage/emulated/ }

Duplicates

OxygenCobalt commented 9 months ago

Since Auxio needs the path of an M3U file to generate relative M3U paths, it uses some really cursed hacks that decodes the path information from the URI given. It's pretty brittle and was only designed with the native file manager.