Android.process.media crashes while trying to get the volume type of path '/storage/...'

REPRODUCIBILITY (% or how often): always for me
BUILD ID = OS VERSION (Settings > About product): 4.3.0.12
HARDWARE (XA2, X10, X10 II, …): XA2
UI LANGUAGE: DE
REGRESSION: (compared to previous public release: Yes, No, ?):
Ever since version 4. Worked on version 4.

DESCRIPTION:

On my device, I can’t access any pictures in galery from android apps. After trying the obvious things (dir permissions, cache, …), I started to dig deeper. I had a look at the android logs:

lxc-attach -n aliendalvik – /system/bin/logcat

→ Android spawns a new process to display media:

12-13 22:18:37.722 13363 13363 E AndroidRuntime: Process: android.process.media, PID: 13363

→ Then has a problem with the storage location of a file and crashes

12-13 22:18:37.722 13363 13363 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.android.providers.downloads.DownloadProvider: java.lang.IllegalStateException: Unknown volume at /storage/128gb/Android/media/org.mozilla.rocket/downloads/others/harbour-storeman-0.2.3-1.sfos3_.4.i486.rpm
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread.access$1300(ActivityThread.java:219)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:107)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.os.Looper.loop(Looper.java:214)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7356)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
12-13 22:18:37.722 13363 13363 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Unknown volume at /storage/128gb/Android/media/org.mozilla.rocket/downloads/others/harbour-storeman-0.2.3-1.sfos3_.4.i486.rpm

12-13 22:18:37.727 164 3937 W ActivityManager: Process android.process.media has crashed too many times: killing!

12-13 22:18:37.742 164 814 E ActivityManager: Timeout waiting for provider com.android.providers.media/10008 for provider media providerRunning=false caller=com.whatsapp/10049
12-13 22:18:37.743 12638 12638 E ActivityThread: Failed to find provider info for media

→ And retries it

12-13 22:18:37.754 39 39 D Zygote : Forked child process 13384
12-13 22:18:37.757 39 39 I Zygote : Process 13363 exited due to signal 9 (Killed)
12-13 22:18:37.757 164 201 I ActivityManager: Start proc 13384:android.process.media/u0a8 for restart android.process.media

→ Until it runs sometimes into a timeout or trashhold with to many tries

The problem is not solved by just deleting the i486.rpm file. Even without it in the filesystem, the error is still there. I only can assume that this entry is in some apps database file and the crash gets triggerd by trying to evaluate the storage location.

And another point: The path 128gb inside /storage/128gb/ does not exist. In the time of SFOS 2 or 3, I installed that card and gave it the name 128gb. This is still shown in the settings->storage. But did not exist as a name in the file system. But even if I simlink the name ‘128gb’ to the uuid of the physical available card path, the crash is still there.

PRECONDITIONS:

Have an old db entry to a file, downloaded to sdcard in the past. And the path to that sdcard does not exists any longer. A later path creation does not help here.

STEPS TO REPRODUCE:

  1. Have a, now non existing, file path to ‘/storage/foo/…’ in some Android apps database
  2. Start an Android App and try to access the Image Galerie
  3. The Image-Picker displays no images at all
  4. Have a look in the android logs

EXPECTED RESULT:

Images in Android Apps get displayed.
The volume type at ‘/sorage/foo’ (foo not existing) gets ignored instead of a crash.

ACTUAL RESULT:

Android tries to respawn the process of parsing a i486.rpm file until it gives up crashing, without showing any pictures.

ADDITIONAL INFORMATION:

logs are shown in the description.

I had a look at the android source here:

https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-29/+/refs/heads/androidx-drawerlayout-release/android/provider/MediaStore.java

On line 1505 will the exception be thrown.

Android tries to find out if the ‘/storage’ place is internal or external one. On my device, within the Android container, ‘/storage’ is the base path, in which the two uuids of available storages (internal and external) are located.

ls /storage

37f129fb-788a-4a39-808d-b7d39323d188 8ff87de4-0b37-4799-b09a-82773e869e07 emulated self

Looking at the Android code, StorageManager.getStorageVolume(path) returns a NULL pointer, which should not happen and throws.

With this more details, still no clue how to fix this.

For reference, this is the code which leads to the crash.

public static @NonNull String getVolumeName(@NonNull File path) {
    if (FileUtils.contains(Environment.getStorageDirectory(), path)) {
        final StorageManager sm = AppGlobals.getInitialApplication()
                .getSystemService(StorageManager.class);
        final StorageVolume sv = sm.getStorageVolume(path);
        if (sv != null) {
            if (sv.isPrimary()) {
                return VOLUME_EXTERNAL_PRIMARY;
            } else {
                return checkArgumentVolumeName(sv.getNormalizedUuid());
            }
        }
        throw new IllegalStateException("Unknown volume at " + path);
    } else {
        return VOLUME_INTERNAL;
    }
}

Okay, I wrote my first Android App to get to know where

Environment.getStorageDirectory()

points to. It is ‘/storage’.

This next line

FileUtils.contains(Environment.getStorageDirectory(), path)

should check it the /storage directory contains the file at the given path. This is not true on my decvice. But, for some reason, is true within the program flow.

StorageManager.getStorageVolume(path)

returns null, as there is no file, which then throws the exception after the if-test.

Now I understand what happens. But still no clue why the program flow discovers a file, where nothing is…

1 Like

Success :-)!

After digging around in the android sqlite db’s, I finally found the source of that entry. It was in

/data/data/com.android.providers.downloads/databases/downloads.db

After removing this file, it gets rebuild and I am able to access the gallery from within Android apps again. Currently, all preview images are broken. New pictures are shown. But finally the functionality is back. Maybe cleaning the gallery cache and rebuilding it, also solves this issue.

So, if someone comes over here with the same problem. Steps:

ssh into your decvice
devel-su su
lxc-attach -n aliendalvik – /system/bin/sh
rm /data/data/com.android.providers.downloads/databases/downloads.db
exit
exit
exit

3 Likes

I have a somewhat similar issue where also the android media service fails to run. My execption is " java.lang.IllegalArgumentException: Invalid volume name: disk" from MediaStore.java#3291

For me it does look like android can not cope with my sdcard being mounted under “disk”. Is there a way for me to change that?

12-17 10:13:24.653    39    39 D Zygote  : Forked child process 28181
12-17 10:13:24.656 28181 28181 E libprocessgroup: Failed to make and chown /acct/uid_10006: Read-only file system
12-17 10:13:24.656 28181 28181 W Zygote  : createProcessGroup failed, kernel missing CONFIG_CGROUP_CPUACCT?
12-17 10:13:24.656 28181 28181 I Zygote  : seccomp disabled by setenforce 0
12-17 10:13:24.657   171   211 I ActivityManager: Start proc 28181:android.process.media/u0a6 for restart android.process.media
12-17 10:13:24.672 28181 28181 E d.process.medi: Not starting debugger since process cannot load the jdwp agent.
12-17 10:13:24.703 28181 28181 I d.process.medi: The ClassLoaderContext is a special shared library.
12-17 10:13:24.743 28181 28181 D AndroidRuntime: Shutting down VM
12-17 10:13:24.743 28181 28181 E AndroidRuntime: FATAL EXCEPTION: main
12-17 10:13:24.743 28181 28181 E AndroidRuntime: Process: android.process.media, PID: 28181
12-17 10:13:24.743 28181 28181 E AndroidRuntime: java.lang.RuntimeException: Unable to get provider com.android.providers.media.MediaProvider: java.lang.IllegalArgumentException: Invalid volume name: disk
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.access$1300(ActivityThread.java:219)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:107)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:214)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7356)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
12-17 10:13:24.743 28181 28181 E AndroidRuntime: Caused by: java.lang.IllegalArgumentException: Invalid volume name: disk
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.provider.MediaStore.checkArgumentVolumeName(MediaStore.java:3295)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at com.android.providers.media.MediaProvider.attachVolume(MediaProvider.java:6036)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at com.android.providers.media.MediaProvider.onCreate(MediaProvider.java:812)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
12-17 10:13:24.743 28181 28181 E AndroidRuntime:        ... 10 more
12-17 10:13:24.746   171 28201 I DropBoxManagerService: add tag=system_app_crash isTagEnabled=true flags=0x2
12-17 10:13:24.746   171 17549 W ActivityManager: Process android.process.media has crashed too many times: killing!

I do have a running android media service, if i simply remove my sdcard.

So my question is: why does sailfish mount my sdcard as “disk” and can i somehow change that? It seems it shoudl always mount the sdcards with their uuid name.

what is the output of

mount

within the sailfish terminal, as well as within the android container on your device?

$ mount
....
/dev/mmcblk1p1 on /run/media/defaultuser/disk type vfat (rw,nosuid,nodev,relatime,uid=100000,gid=100000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

similar from within the container:
/dev/mmcblk1p1 on /mnt/media_rw/alien_external_storage/disk type vfat (rw,nosuid,nodev,relatime,uid=100000,gid=100000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro)

Strange. And what is the output of:

blkid

$ blkid

...
/dev/mmcblk1p1: LABEL_FATBOOT="NIKON D90" LABEL="NIKON D90" TYPE="vfat"
...

i also checked the status un udiskctl:

$ udisksctl info -b /dev/mmcblk1p1

/org/freedesktop/UDisks2/block_devices/mmcblk1p1:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/mmcblk1p1
    DeviceNumber:               45889
    Drive:                      '/org/freedesktop/UDisks2/drives/SL64G_0x2d308832'
    HintAuto:                   true
    HintIconName:
    HintIgnore:                 false
    HintName:
    HintPartitionable:          true
    HintSymbolicIconName:
    HintSystem:                 false
    Id:                         by-label-NIKON\x20D90
    IdLabel:                    NIKON D90
    IdType:                     vfat
    IdUUID:
    IdUsage:                    filesystem
    IdVersion:                  FAT32
    MDRaid:                     '/'
    MDRaidMember:               '/'
    PreferredDevice:            /dev/mmcblk1p1
    ReadOnly:                   false
    Size:                       63860375552
    Symlinks:                   /dev/block/mmcblk1p1
                                /dev/disk/by-id/mmc-SL64G_0x2d308832-part1
                                /dev/disk/by-label/NIKON\x20D90
                                /dev/disk/by-path/platform-4784000.sdhci-part1
    UserspaceMountOptions:      uhelper=udisks2
  org.freedesktop.UDisks2.Filesystem:
    MountPoints:        /run/media/defaultuser/disk
    Size:               0
  org.freedesktop.UDisks2.Partition:
    Flags:              0
    IsContained:        false
    IsContainer:        false
    Name:
    Number:             1
    Offset:             4194304
    Size:               63860375552
    Table:              '/org/freedesktop/UDisks2/block_devices/mmcblk1'
    Type:               0x0c
    UUID:

does anybody know where udisk takes the mount name from? documentaion suggests in fact uuid, but for me this seems to be different.

I only now noticed, my sd card does not have a uuid, it seems there is something wrong with my sdcard.

i mounted it in my pc and ran fsck on it + gave it a new uuid.

Now it is mounted under its uuid on my phone and everything works as expected :slight_smile:

1 Like