OxygenCobalt / Auxio

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

Music loading fails on all Huawei devices #592

Closed tsafs closed 5 months ago

tsafs commented 8 months ago

Describe the Bug/Crash

  1. Own Huawei P20 Smartphone
  2. Open app
  3. Grant permissions
  4. See this error

Describe the intended behavior

Should load music

What android version do you use?

Android 10

What device model do you use?

Huawei P20

Bug report

java.lang.NullPointerException at org.oxycblt.auxio.music.fs.BaseApi29MediaStoreExtractor$Query.populateFileInfo(SourceFile:53) at org.oxycblt.auxio.music.fs.BaseMediaStoreExtractor.consume(SourceFile:126) at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$mediaStoreJob$1.invokeSuspend(SourceFile:47) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(Unknown Source:8) at kotlinx.coroutines.DispatchedTask.run(Unknown Source:107) at androidx.core.app.ActivityRecreator$1.run(SourceFile:19) at kotlinx.coroutines.scheduling.TaskImpl.run(Unknown Source:2) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(SourceFile:94)

Duplicates

OxygenCobalt commented 8 months ago

From the looks of it, #120 actually exists on all Huawei P20 phones, not just the ones below Android 10. Sigh...

Thanks for reporting this.

ChristianCiach commented 8 months ago

Same issue with a Huawei Matepad 11 (2021), updated to HarmonyOS 3.0 (which is essentially Android 12 as reported by CPU-Z). Stacktrace is exactly the same as shown by OP above.

OxygenCobalt commented 7 months ago

Sorry for the wait. Here's a debug APK that should dump some valuable information for me in the music loading stack trace. Try it and report the new error that pops up @tsafs @ChristianCiach.

Auxio_MoreLogging.zip

ChristianCiach commented 7 months ago

@OxygenCobalt Here is the new stacktrace:

java.lang.Exception: Directory not present [StorageVolume: Interner Speicher null]
    at org.oxycblt.auxio.music.fs.BaseApi29MediaStoreExtractor$Query.populateFileInfo(MediaStoreExtractor.kt:520)
    at org.oxycblt.auxio.music.fs.BaseMediaStoreExtractor.consume(MediaStoreExtractor.kt:207)
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$mediaStoreJob$1.invokeSuspend(MusicRepository.kt:416)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
OxygenCobalt commented 7 months ago

Huh. So Huawei/HarmonyOS doesn't provide the relative path of all things. I guess I'll have to make a huawei-specific music loader that has the #120 fix and a mitigation for this too, probably by using the older absolute path field.

5x44 commented 6 months ago

Hello, I hope you are well. The bug you mentioned about Huawei devices is due to limitations in reading and writing applications in the Huawei ecosystem, here are the steps to solve it.

  1. Open Auxio
  2. Go to Settings/Music Folders/Include
  3. Choose a folder were your music will be stored (I recommend choosing /Music directory then move your tracks to this directory).
OxygenCobalt commented 6 months ago

Weird. So Huawei has some kind of scoped storage on steroids where it will flat out refuse path data unless you've been granted file system access to them @Ox55? In that case, #322 should also eventually allow me to completely resolve this without stupid hacks (Albeit for now I'll do the workaround from prior internally).

ChristianCiach commented 6 months ago

I can confirm that the setup described by @Ox55 works on my Matepad 11 with HarmonyOS 3.0. That's a neat workaround, thanks!

5x44 commented 6 months ago

Weird. So Huawei has some kind of scoped storage on steroids where it will flat out refuse path data unless you've been granted file system access to them @Ox55? In that case, #322 should also eventually allow me to completely resolve this without stupid hacks (Albeit for now I'll do the workaround from prior internally).

Huawei's system has some particularities, for example, the permission to read and write to the /data and /obb directories (tested in Harmony OS 2.0 and EMUI 12) without the use of a computer or the famous split-screen method, commonly used to copy information to these directories. A pop-up to choose directories in the first configuration of Auxio, or a function so that in the first configuration, Auxio looks for the /storage/emulated/0/Music directory, which is the default music directory in most Android-derived builds, can help solve this problem, as mentioned in #322.

@OxygenCobalt

OxygenCobalt commented 6 months ago

Alright @Ox55, thanks for that explanation. Huawei just casually violating the API documentation in their own android skin, lol

OxygenCobalt commented 5 months ago

Care to try this APK @tsafs @Ox55 @ChristianCiach @Admin31019?

Auxio_Canary.zip

I had to make a guess on how to determine if the device is made by huawei, and I don't know if harmonyos will get angry at my workaround or not, so it still might not be working.

ChristianCiach commented 5 months ago

@OxygenCobalt Doesn't work for me:

java.lang.IllegalStateException: MediaStore discovery is deadlocked
    at org.oxycblt.auxio.music.MusicRepositoryImpl.indexImpl(MusicRepository.kt:494)
    at org.oxycblt.auxio.music.MusicRepositoryImpl.access$indexImpl(MusicRepository.kt:222)
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$1.invokeSuspend(Unknown Source:16)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:115)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:103)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
5x44 commented 5 months ago

@OxygenCobalt Isn't loading music.

OxygenCobalt commented 5 months ago

Removed that deadlock check since its probably being done in error, care to try this one @tsafs @Ox55 @ChristianCiach @Admin31019?

Auxio_Canary.zip

ChristianCiach commented 5 months ago

@OxygenCobalt Now it just says "No music found" (in german), even though their is plenty of music on the device that gets found by other music players. I've tried again after clearing the app data, but no change.

Even worse: The workaround to add my music folder to the list of music folders in the settings doesn't work anymore; still "No music found". But no crashes.

OxygenCobalt commented 5 months ago

Oh, wait, my change created a new bug @ChristianCiach. Let me fix that.

OxygenCobalt commented 5 months ago

Third times the charm. Can you try this @tsafs @Ox55 @ChristianCiach @Admin31019?

Auxio_Canary.zip

ChristianCiach commented 5 months ago

@OxygenCobalt

java.lang.Exception: DeviceLibrary creation failed: java.lang.IllegalArgumentException: Invalid raw null: No path
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$deviceLibraryJob$1.invokeSuspend(MusicRepository.kt:471)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Better luck next time :)

ChristianCiach commented 5 months ago

Configuring the music folder prevents the crash, but results in "No music found" again.

ChristianCiach commented 5 months ago

Maybe I could grant you some kind of remote access to my device, using TeamViewer or something like that? I don't use my tablet a lot, so I wouldn't mind you controlling my device unattended.

OxygenCobalt commented 5 months ago

No, I don't really need to remote pilot a device. I am getting a grasp of the issue and can simply send another test APK that allows me to confirm what I'm thinking is going on.

Anyway, that's not a good sign at all. That implies that Huawei might also be denying me the DATA path, because it really does just hate media apps. I wonder what the probability is of their music app just happening to not have these restrictions? What a horrible OEM.

Here's a test APK that allows me to confirm that hunch. Report the stack trace @ChristianCiach:

Auxio_Canary.zip

ChristianCiach commented 5 months ago
java.lang.Exception: DeviceLibrary creation failed: java.lang.Exception: Tag extraction failed: java.lang.Exception: MediaStore extraction failed: e
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$deviceLibraryJob$1.invokeSuspend(MusicRepository.kt:471)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
OxygenCobalt commented 5 months ago

Templating error :facepalm:. One second

OxygenCobalt commented 5 months ago

Trying again:

Auxio_Canary.zip

OxygenCobalt commented 5 months ago

@ChristianCiach

ChristianCiach commented 5 months ago
java.lang.Exception: DeviceLibrary creation failed: java.lang.Exception: Tag extraction failed: java.lang.Exception: MediaStore extraction failed: java.lang.IllegalStateException: Could not find volume for path hw_product/media/Pre-loaded/Music/Dream_It_Possible.flac (tried: [InternalVolumeImpl(storageVolume=StorageVolume: Interner Speicher), ExternalVolumeImpl(storageVolume=StorageVolume: Samsung-Speicherkarte (7434-8B91))])
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$deviceLibraryJob$1.invokeSuspend(MusicRepository.kt:471)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)

Thank you for putting up with us Huawei device owners, by the way. I would totally understand if you had decided to just not bother with these devices.

But for all of its shortcomings (mainly the missing Google services), I still think this is a great device. I picked up this tablet two years ago for like 200 Euro (keyboard and pen included) and I think it's still incredible value.

The hardware still feels premium. I just wish the bootloader was unlockable. I would probably try to port LineageOS by myself. I did it once and I can to it again!

OxygenCobalt commented 5 months ago

hw_product/media/Pre-loaded/Music/Dream_It_Possible.flac

...I have never seen this path before. I'm going to quickly confirm the volumes aren't spitting out this path, and if so then I'm just going to hard-code this prefix and hope things don't break.

Quick question: Is your music on an SD card or on your internal storage.

ChristianCiach commented 5 months ago

The music is on the internal storage under /Music.

OxygenCobalt commented 5 months ago

Alright, so I assume then this is Huaweis specific /storage/emulated/0 equivalent, and they just didn't update the volume to indicate that path. I need to confirm this first.

ChristianCiach commented 5 months ago

That being said, I cannot find a file named "Dream_it_possible.flac" anywere inside this folder (or anywhere else, really). Let me check where it gets the filename from. This is weird..

OxygenCobalt commented 5 months ago

Perhaps it's actually a default Huawei ringtone thing? That's weird to just show up in Auxio like that, especially if you have "Exclude non-music" enabled.

OxygenCobalt commented 5 months ago

Another APK: Auxio_Canary.zip

OxygenCobalt commented 5 months ago

@ChristianCiach

ChristianCiach commented 5 months ago

Before I try your new APK, check this out: Yes, Dream_it_possible.flac is actually the sole music file that is just shipped by Huawei as part of the System. Huawei's stock music player shows the song and also its path:

Screenshot_20240101_210053_com huawei music

I probably cannot even delete it, because no file browser lets me access the root directory.

ChristianCiach commented 5 months ago
java.lang.Exception: DeviceLibrary creation failed: java.lang.Exception: Tag extraction failed: java.lang.Exception: MediaStore extraction failed: java.lang.IllegalStateException: Could not find volume for path hw_product/media/Pre-loaded/Music/Dream_It_Possible.flac (tried: [storage/emulated/0, storage/7434-8B91]})
    at org.oxycblt.auxio.music.MusicRepositoryImpl$indexImpl$deviceLibraryJob$1.invokeSuspend(MusicRepository.kt:471)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
OxygenCobalt commented 5 months ago

Wow. So huawei just...doesn't list a volume for it's preloaded stuff. Wonderful. In this case I'm just going to have to filter them out then.

5x44 commented 5 months ago

Recent Huawei devices do not have an SD card slot, the methodology that Huawei used is a proprietary SD card that is inserted into the SIM slot, which is why most, if not all, recent Huawei devices use two SIM cards. The track 'Dream it Possible' comes by default on Huawei devices, the system added the track in a path not reachable by the normal user. To listen to the track 'Dream is Possible' just open the default music application, the music will be there if you haven't deleted it, as the system allows this but the music will return when you format the device, and yes, the original Music app has high privileges.

Note: You'll need to use the default Music app to delete this track.

OxygenCobalt commented 5 months ago

I think I'm not going to filter them out. I'll leave them in, but with a kind of "Other volume" signifier. The songs will sadly only be removable currently by including another music folder.

Also, the fact that this exists and can't be resolved via a file manager seems like justification for Auxio to have song deletion. I'm opening an issue for that. Thanks Huawei, you've successfully convinced me to accept a feature that I would normally reject.

Never mind, this issue will be resolved with #322, which by it's nature won't accidentally pick up music from other parts of the device.

ChristianCiach commented 5 months ago

I don't think Auxio needs a deletion feature. This is a single file that can easily deleted using the stock music player. Any other files can be deleted using a regular file explorer or through MTP. I think it's sufficient to just filter files without volumes or add it to a virtual album -- your choice, of course. I just don't feel a deletion feature is a reasonable reaction to such an edge case :)

OxygenCobalt commented 5 months ago

Alright, try this APK @ChristianCiach

Auxio_Canary.zip

ChristianCiach commented 5 months ago

@OxygenCobalt It works! It just works, even after deleting all app data and without configuring any included folders.

Great work, and thanks again for going out of your way to support our exotic devices!

OxygenCobalt commented 5 months ago

Fantastic. Thank you so much for holding through all the debug builds, it's great when someone is this receptive to testing.

ChristianCiach commented 5 months ago

it's great when someone is this receptive to testing.

Likewise! Huge respect for being this responsive when it comes to answering bug reports and providing debug builds! This reminds me of simpler times when I had enough time to closely interact with the users of my ROM over at XDA. Anyway, thanks for Auxio and keep up the good work!