phhusson / treble_experimentations

Notes about tinkering with Android Project Treble
3.4k stars 660 forks source link

[Huawei Mediapad M5] [AOSP 11 v308] Chrome freezes UI after a minute. DRM problem? #1885

Open presslab-us opened 3 years ago

presslab-us commented 3 years ago

Anything that uses Chrome browsing engine (Brave, etc) freezes up the UI after a minute. I can still see any web page updates but I can't scroll or do anything. I can force close Chrome and tablet is otherwise fine after that.

Right when the freeze occurs, logs show problems with Widevine DRM:

......
06-05 07:52:02.049 13467 13467 I cr_media: Create MediaDrmBridge with level L3 and origin 851F4B94E6FBA8AF8D66E018765FC96C
06-05 07:52:02.064 13467 13467 I DrmUtils: found android.hardware.drm@1.0::IDrmFactory clearkey
06-05 07:52:02.067 13467 13467 I DrmUtils: found android.hardware.drm@1.0::IDrmFactory default
06-05 07:52:02.069   384   384 I hwservicemanager: Since android.hardware.drm@1.0::IDrmFactory/widevine is not registered, trying to start it as a lazy HAL.
06-05 07:52:02.071   384   384 I hwservicemanager: Since android.hardware.drm@1.0::IDrmFactory/widevine is not registered, trying to start it as a lazy HAL.
06-05 07:52:02.072 13467 13467 I HidlServiceManagement: getService: Trying again for android.hardware.drm@1.0::IDrmFactory/widevine...
06-05 07:52:03.079 13467 13467 W HidlServiceManagement: Waited one second for android.hardware.drm@1.0::IDrmFactory/widevine
06-05 07:52:03.081   384   384 I hwservicemanager: Since android.hardware.drm@1.0::IDrmFactory/widevine is not registered, trying to start it as a lazy HAL.
06-05 07:52:03.083 13467 13467 I HidlServiceManagement: getService: Trying again for android.hardware.drm@1.0::IDrmFactory/widevine...
06-05 07:52:03.911   917   917 E WifiHAL : enter wifi_get_link_stats
06-05 07:52:04.084 13467 13467 W HidlServiceManagement: Waited one second for android.hardware.drm@1.0::IDrmFactory/widevine
06-05 07:52:04.085   384   384 I hwservicemanager: Since android.hardware.drm@1.0::IDrmFactory/widevine is not registered, trying to start it as a lazy HAL.
06-05 07:52:04.086 13467 13467 I HidlServiceManagement: getService: Trying again for android.hardware.drm@1.0::IDrmFactory/widevine...
......

and dmesg shows:

......
[ 3125.566802] [pid:1,cpu3,init]init: Control message: Could not find 'android.hardware.drm@1.0::IDrmFactory/widevine' for ctl.interface_start from pid: 384 (/system/bin/hwservicemanager)
......

On startup there is this error:

--------- beginning of system
06-05 07:01:17.656   393   393 I vold    : Vold 3.0 (the awakening) firing up
06-05 07:01:17.657   393   393 D vold    : Detected support for: ext4 f2fs vfat
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop1: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop2: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop3: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop7: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop4: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop0: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop5: No such device or address
06-05 07:01:17.660   393   393 W vold    : Failed to LOOP_GET_STATUS64 /dev/block/loop6: No such device or address
06-05 07:01:17.660   393   393 I vold    : [libfs_mgr]dt_fstab: Using a specified mount point /vendor/preavs for preavs
06-05 07:01:17.664   393   393 D vold    : VoldNativeService::start() completed OK
06-05 07:01:17.668   393   401 I vold    : Found disk at /devices/platform/hi_mci.1/mmc_host/mmc1/mmc1:59b4/block/mmcblk1 but delaying scan due to secure keyguard
06-05 07:01:21.523   393   393 I Checkpoint: cp_prepareCheckpoint called
06-05 07:01:21.533   393   393 I vold    : fscrypt_initialize_systemwide_keys
06-05 07:01:21.534   393   393 D vold    : Key exists, using: /data/unencrypted/key
06-05 07:01:21.655   393   393 I vold    : List of Keymaster HALs found:
06-05 07:01:21.655   393   393 I vold    : Keymaster HAL #1: Keymaster2 Hisi HAL from TrustedCore Team SecurityLevel: TRUSTED_ENVIRONMENT HAL: android.hardware.keymaster@3.0::IKeymasterDevice/default
06-05 07:01:21.655   393   393 I vold    : Using Keymaster2 Hisi HAL from TrustedCore Team for encryption.  Security level: TRUSTED_ENVIRONMENT, HAL: android.hardware.keymaster@3.0::IKeymasterDevice/default
06-05 07:01:21.672   393   393 I vold    : Kernel doesn't support FS_IOC_ADD_ENCRYPTION_KEY.  Falling back to session keyring
06-05 07:01:21.673   393   393 D vold    : Added key 679760373 (ext4:99cc6c65dc83a7ca) to keyring 144792277 in process 393
06-05 07:01:21.673   393   393 D vold    : Added key 431850339 (f2fs:99cc6c65dc83a7ca) to keyring 144792277 in process 393
06-05 07:01:21.673   393   393 D vold    : Added key 1044713385 (fscrypt:99cc6c65dc83a7ca) to keyring 144792277 in process 393
06-05 07:01:21.673   393   393 I vold    : Wrote system DE key reference to:/data/unencrypted/ref
06-05 07:01:21.673   393   393 D vold    : Added key 274226685 (ext4:efb6ae5764ae9407) to keyring 144792277 in process 393
06-05 07:01:21.673   393   393 D vold    : Added key 441394406 (f2fs:efb6ae5764ae9407) to keyring 144792277 in process 393
06-05 07:01:21.673   393   393 D vold    : Added key 939117278 (fscrypt:efb6ae5764ae9407) to keyring 144792277 in process 393
06-05 07:01:21.674   393   393 I vold    : Wrote per boot key reference to:/data/unencrypted/per_boot_ref
06-05 07:01:21.940   393   393 D vold    : fscrypt_init_user0
06-05 07:01:21.940   393   393 D vold    : Preparing: /data/misc/vold/user_keys
06-05 07:01:21.940   393   393 D vold    : Preparing: /data/misc/vold/user_keys/ce
06-05 07:01:21.940   393   393 D vold    : Preparing: /data/misc/vold/user_keys/de
06-05 07:01:21.941   393   393 D vold    : Skipping non-de-key .
06-05 07:01:21.941   393   393 D vold    : Skipping non-de-key ..
06-05 07:01:21.945   393   393 I vold    : List of Keymaster HALs found:
06-05 07:01:21.945   393   393 I vold    : Keymaster HAL #1: Keymaster2 Hisi HAL from TrustedCore Team SecurityLevel: TRUSTED_ENVIRONMENT HAL: android.hardware.keymaster@3.0::IKeymasterDevice/default
06-05 07:01:21.945   393   393 I vold    : Using Keymaster2 Hisi HAL from TrustedCore Team for encryption.  Security level: TRUSTED_ENVIRONMENT, HAL: android.hardware.keymaster@3.0::IKeymasterDevice/default
06-05 07:01:21.957   393   393 D vold    : Added key 384155524 (ext4:5941c5ef91ee5e8c) to keyring 144792277 in process 393
06-05 07:01:21.957   393   393 D vold    : Added key 850055352 (f2fs:5941c5ef91ee5e8c) to keyring 144792277 in process 393
06-05 07:01:21.957   393   393 D vold    : Added key 582057327 (fscrypt:5941c5ef91ee5e8c) to keyring 144792277 in process 393
06-05 07:01:21.957   393   393 D vold    : Installed de key for user 0
06-05 07:01:21.957   393   393 D vold    : fscrypt_prepare_user_storage for volume null, user 0, serial 0, flags 1
06-05 07:01:21.958   393   393 D vold    : Preparing: /data/system/users/0
06-05 07:01:21.959   393   393 D vold    : Preparing: /data/misc/profiles/cur/0
06-05 07:01:21.960   393   393 D vold    : Preparing: /data/system_de/0
06-05 07:01:21.960   393   393 D vold    : Preparing: /data/misc_de/0
06-05 07:01:21.961   393   393 D vold    : Preparing: /data/vendor_de/0
06-05 07:01:21.961   393   393 D vold    : Preparing: /data/user_de/0
06-05 07:01:21.962   393   393 I vold    : Verified that /data/system_de/0 has the encryption policy 5941c5ef91ee5e8c v1 modes 1/4 flags 0x0
06-05 07:01:21.962   393   393 I vold    : Verified that /data/misc_de/0 has the encryption policy 5941c5ef91ee5e8c v1 modes 1/4 flags 0x0
06-05 07:01:21.962   393   393 I vold    : Verified that /data/vendor_de/0 has the encryption policy 5941c5ef91ee5e8c v1 modes 1/4 flags 0x0
06-05 07:01:21.962   393   393 I vold    : Verified that /data/user_de/0 has the encryption policy 5941c5ef91ee5e8c v1 modes 1/4 flags 0x0
06-05 07:01:21.962   393   393 D vold    : /system/bin/vold_prepare_subdirs
06-05 07:01:21.962   393   393 D vold    :     prepare
06-05 07:01:21.962   393   393 D vold    :     
06-05 07:01:21.962   393   393 D vold    :     0
06-05 07:01:21.962   393   393 D vold    :     1
--------- beginning of crash
06-05 07:01:22.561   883   883 F linker  : CANNOT LINK EXECUTABLE "/vendor/preavs/bin/hw/android.hardware.drm@1.1-service.widevine": library "libdexfile.so" not found: needed by /vendor/preavs/lib/libbacktrace.so in na
mespace (default)
06-05 07:01:22.622   937   937 I gsid    : no DSU: No such file or directory
06-05 07:01:22.678   917   917 I vendor.huawei.hardware.hwwifiext@1.1-service: Wifi Hal 1.1 is starting up...
06-05 07:01:23.375   830   830 D Zygote32Timing: PostZygoteInitGC took to complete: 11ms
06-05 07:01:23.375   830   830 D Zygote32Timing: ZygoteInit took to complete: 20ms
06-05 07:01:23.398   829   829 D Zygote64Timing: BeginPreload took to complete: 32ms
06-05 07:01:23.871  1082  1082 I wificond: wificond is starting up...
06-05 07:01:23.875  1082  1082 I HidlServiceManagement: Registered android.system.wifi.keystore@1.0::IKeystore/default
06-05 07:01:23.943  1091  1091 I installd: installd firing up
06-05 07:01:24.111  1087  1087 D Zygote32Timing: PostZygoteInitGC took to complete: 8ms
06-05 07:01:24.111  1087  1087 D Zygote32Timing: ZygoteInit took to complete: 12ms
06-05 07:01:24.128  1086  1086 D Zygote64Timing: BeginPreload took to complete: 8ms
06-05 07:01:24.868  1086  1086 I PackageParser: Skipping target and overlay pair android and /system/product/overlay/treble-overlay-asus-zenfone5-10.apk: overlay ignored due to required system property: ro.product.vend
or.name with value: ASUS_X00QD
......

When I run "DRM Info" app, it does not open and freezes with the same error messages in the logs.

I'd be ok to just disable Widevine altogether but I'm not sure how to do that. I am able to build this repo so if there is something to try I can test it.

presslab-us commented 3 years ago

I installed the libdexfile.so dependency and now I see this: 06-06 07:48:43.528 881 881 F linker : CANNOT LINK EXECUTABLE "/vendor/preavs/bin/hw/android.hardware.drm@1.1-service.widevine": cannot locate symbol "_ZNK7android4h idl4base4V1_08BnHwBase13checkSubclassEPKv" referenced by "/system/lib/android.hardware.drm@1.0.so"...

presslab-us commented 3 years ago

I tried a bunch of stuff. I looked for a widevine library from a newer Huawei rom, but all the ones I found still have the ABI issues. I tried numerous ways to disable hwservicemanager from trying to load android.hardware.drm@1.0::IDrmFactory/widevine but no luck.

I have attached the ANR log from Chrome: anr_2021-06-09-05-00-47-737.txt

Iceows commented 2 years ago

Chrome freeze also in lineage 18.1 on P20 and mediapad T5

Iceows commented 2 years ago

To fix the problem

setprop persist.sys.restart.mediadrm false

service drm-widevine-hal-1-0 /vendor/bin/hw/android.hardware.drm@1.0-service.widevine class hal user media group mediadrm drmrpc ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks setenv LD_LIBRARY_PATH /vendor/lib

on property:persist.sys.restart.mediadrm=true restart drm-widevine-hal-1-0 setprop persist.sys.restart.mediadrm false

set correct permission and selinux label to android.hardware.drm@1.0-service.widevine, libunwind.so and libwvhidl.so

presslab-us commented 9 months ago

Thanks for the help @Iceows! I am just now trying this again :smile:

With the preavs partition I can extract all the files needed (mine shows 1.1 and 1.2 widevine).

But with vendor_a I cannot extract all the files. I have copied the image and can mount it fine. But I get these errors on many files. I get the same errors if I create the image from the mmcblk0p56 or if I use the vendor_image.emmc.win image from UPDATE.APP.

[1288147.966190] erofs: (device loop1): z_erofs_readahead: readahead error at folio 1 @ nid 2672484
[1288147.966385] erofs: (device loop1): z_erofs_read_folio: read error -117 @ 1 of nid 2672484
[1288147.966390] erofs: (device loop1): z_erofs_read_folio: read error -117 @ 1 of nid 2672484
[1288147.966428] erofs: (device loop1): z_erofs_read_folio: read error -117 @ 1 of nid 2672484
# uname -a
Linux socrates 6.6.9-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan  1 20:05:54 UTC 2024 x86_64 GNU/Linux
# 

When I look at the copied files they are 0 size. Maybe I need an older kernel to extract?

Iceows commented 8 months ago

Do you have install erofs utilities ? Kirin710 use erofs filesystem on vendor partition

presslab-us commented 8 months ago

Yes, I have tried using fsck.erofs --extract=vendor_a and also mounting the share (errors as shown above). I have downloaded many different programs to extract the erofs image but they all have errors when I try to extract.

presslab-us commented 8 months ago

I was able to copy the vendor files from the phone using root. I noticed I already have the same widevine files in /vendor/preavs

My init script is as below. It looks like it it copying something from the system partition on startup. And since I don't have the original system partition this isn't working. I will look next at the original system partition to see what files it is copying.

on property:init.svc.mediadrm=running
    mkdir /data/vendor/mediadrm 0770 media mediadrm
    start vendor.move_data_sh

service vendor.move_data_sh /system/bin/move_widevine_data.sh
    class late_start
    user media
    group media mediadrm system
    disabled
    oneshot

service vendor.drm-widevine-hal-1-1 /vendor/preavs/bin/hw/android.hardware.drm@1.1-service.widevine
    interface android.hardware.drm@1.1::ICryptoFactory widevine
    interface android.hardware.drm@1.1::IDrmFactory widevine
    class hal
    user media
    group media mediadrm drmrpc
    ioprio rt 4
    writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks
    setenv LD_LIBRARY_PATH /vendor/preavs/lib:/vendor/wv_lib

on property:persist.odm.restart.mediadrm=true
    restart vendor.drm-widevine-hal-1-1
    setprop persist.odm.restart.mediadrm false

on property:odm.drm.stop=true
    stop vendor.drm-widevine-hal-1-1
    setprop odm.drm.stop false
Iceows commented 8 months ago

But why you don't use twrp and mount preavs partition with erofs type ?

Le lun. 12 févr. 2024, 18:04, presslab-us @.***> a écrit :

I was able to copy the vendor files from the phone using root. I noticed I already have the same widevine files in `/vendor/preavs'

My init script is as below. It looks like it it copying something from the system partition on startup. And since I don't have the original system partition this isn't working. I will look next at the original system partition to see what files it is copying.

on property:init.svc.mediadrm=running mkdir /data/vendor/mediadrm 0770 media mediadrm start vendor.move_data_sh

service vendor.move_data_sh /system/bin/move_widevine_data.sh class late_start user media group media mediadrm system disabled oneshot

service vendor.drm-widevine-hal-1-1 @. interface @.::ICryptoFactory widevine interface @.***::IDrmFactory widevine class hal user media group media mediadrm drmrpc ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks setenv LD_LIBRARY_PATH /preavs/lib

on property:persist.odm.restart.mediadrm=true restart vendor.drm-widevine-hal-1-1 setprop persist.odm.restart.mediadrm false

on property:odm.drm.stop=true stop vendor.drm-widevine-hal-1-1 setprop odm.drm.stop false

— Reply to this email directly, view it on GitHub https://github.com/phhusson/treble_experimentations/issues/1885#issuecomment-1939161054, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVDNGLRDP767IUBNR6I6S4TYTJDSRAVCNFSM46EPEY6KU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTHEYTMMJQGU2A . You are receiving this because you were mentioned.Message ID: @.***>

presslab-us commented 8 months ago

I have only been able to make this old TWRP work. It can't mount those erofs partitions (and not system from LineageOS 21 anymore either). Maybe you can think of a newer one that's working for Mediapad M5? https://xdaforums.com/t/recovery-8-0-unofficial-twrp-3-2-1-0-for-emui-8-0-06-05-2018.3773449/

I've looked at the EMUI 9 SYSTEM.img and I can't see any /system/bin/move_widevine_data.sh. So I don't know where to go from there :smile:

I was able to (mostly) make a new vendor image with mkfs.erofs. It boots fine but for some reason the fingerprint reader has an error with my generated image. At first it would not boot at all but once I figured out how to build with selinux properties the new image worked.

Maybe I can try to find a boot log to see what the errors are with this widevine service?