Skip to content

Root module service can hang before unlock and should fail fast on known version mismatch #579

@imdinkie

Description

@imdinkie

Environment

  • Device: Pixel 7 Pro (cheetah)
  • Android: 16 / API 36
  • Root: Magisk 30.7
  • Module: YouTube Morphe root module generated by Morphe Manager flow

Problem

The generated root module service script can remain running after boot when /sdcard/Android is unavailable before first unlock.

On my device, while locked/direct-boot-ish, /sdcard existed as a symlink:

/sdcard -> /storage/self/primary

but /sdcard/Android did not exist yet, so the script waited indefinitely here:

until [ -d "/sdcard/Android" ]; do sleep 1; done

Unlocking the phone likely lets this continue. It can still leave a boot service process hanging and make debugging other startup problems noisier.

Version mismatch case

In my case, the Morphe APK and stock YouTube version did not match:

Morphe APK versionName: 20.47.62
Installed stock YouTube versionName: 20.10.41
Installed stock YouTube path: /product/app/YouTube/YouTube.apk

The script is right to refuse mounting when versions mismatch.

However, under the root service context, these returned no base path:

pm path com.google.android.youtube
cmd package path com.google.android.youtube

while dumpsys package com.google.android.youtube still returned useful information, including versionName and codePath.

Local workaround

I locally patched the generated service script to:

  • bound the /sdcard/Android wait
  • avoid global stdout/stderr redirection being inherited by package-manager commands
  • use dumpsys package codePath= as a fallback for system YouTube
  • exit immediately once a version mismatch is known, instead of continuing path retries

With this, the script logs and exits cleanly:

base_path: /data/adb/modules/com.google.android.youtube-morphe/com.google.android.youtube.apk
stock_path: /product/app/YouTube/YouTube.apk
base_version: 20.47.62
stock_versions: 20.10.41
Not mounting as versions don't match

Question

Would you accept a PR that makes the generated root module service script:

  • avoid indefinite pre-unlock /sdcard/Android waits
  • fall back to dumpsys package codePath= for system apps
  • fail fast when a stock/patched version mismatch is already known?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions