topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
48.66k stars 12.46k forks source link

Hiding and Restoring Magisk App not consistently working properly on many devices #6309

Closed Dusk-Golem closed 1 year ago

Dusk-Golem commented 2 years ago

Device: Samsung Galaxy A8 2018 (SM-A530F) Android version: Android 9.0 (Stock Rom, Nov 2021 Security Patch) Magisk version name: 38ab6858 (25203) (34) Canary + Debug Magisk version code: 38ab6858 (25203) (34) Canary + Debug

So, as apparent from the title, I have been facing issues with hiding and restoring magisk app v25.x. I have clean installed my stock rom for these tests. I tried latest canary as well as debug build and these are the issues;

CANARY VERSION For this version, when i first hide magisk app, the "settings" shortcut created begans to ask me of root permissions which when i grant it hides the magisk app and start magisk from the shortcut but it is now unable to detect zygisk status (says no even when active). I have to revoke the su permission i granted when the shortcut was being created, clear the app activity from recent apps list and then again start magisk from the shortcut but this time it works fine and will continue to work untill i try to restore the app.

Now, when i restore the magisk app, first it proceeds normally and then suddenly exits. After this, the magisk app is not restored and the shortcut is still there so i have to manually uninstall the "settings" shortcut and install the magisk apk to finally restore the app which brings back everything to normal.

THESE SAME ISSUES OCCUR WITH THE STABLE BUILD.

DEBUG VERSION None of the issues i mentioned above occur in debug version, magisk app behaves normally.

CONCLUSION I have gathered all the possible logs (magisk log, logcat during hiding restoring, bootlog, etc) for the canary as well as debug build. Kindly refer to them for detailed info. The file names are self explanatory.

DEBUG BUILD LOGS.zip CANARY BUILD LOGS.zip

pndwal commented 2 years ago

Well done!

I've fielded countless examples of this/similar issue in XDA Magisk discussion thread, so know it's actually a widespread issue affecting many devices...

Here's a little strategy I posted re. Magisks failure to uninstall full app when taking "Hide the Magisk app", or failure to uninstall the stub app when taking "Restore the Magisk app" which also results in requests for SU permission, Magisk Installed = NA, etc, etc: https://forum.xda-developers.com/t/magisk-general-support-discussion.3432382/post-87044311

... It's not fixed...

Dusk-Golem commented 2 years ago

I also like to add that this failure to hide and restore occurs randomly. When the app fails to hide or restore the itself and then you try to do the same (hide or restore) immediately after the failure then it works normally. So, may be this issue occurs under a certain condition and that is unknown to me and many I suppose. I hope someone can figure this out soon.

pndwal commented 2 years ago

Same random occurrences observed... Successfully taking Hide the Magisk app (without any user intervention) occurs possibly less than 50% of the time for me...

Another issue, ie. failure to update App successfully in hidden state (we also end up with competing stub and full app), is probably much older but likely related and also occurs with a similar rate of failure...

I wasn't aware that this issue is absent in Debug builds... This could be a useful clue, especially if it happens to be linked to the strange failure of release-built Apps to open at all on certain devices while debug-built Apps (inexplicably) open without issue (https://github.com/topjohnwu/Magisk/issues/6257)...

Unknown78 commented 1 year ago

@pndwal @DarkKnight1995 Hey guys, the issue and fix has been found, checkout the latest discussion of #6257. It will be in the next magisk-release build I suppose.

Dusk-Golem commented 1 year ago

@pndwal @DarkKnight1995 Hey guys, the issue and fix has been found, checkout the latest discussion of #6257. It will be in the next magisk-release build I suppose.

Don't know mate. My device is running stock android 9.0, kernel version: 4.4.111-22928167, I will wait for the next release to test it again with fresh os install. Untill then, debug build it is.

pndwal commented 1 year ago

@pndwal @DarkKnight1995 Hey guys, the issue and fix has been found, checkout the latest discussion of #6257. It will be in the next magisk-release build I suppose.

This issue and yours (doesn't occur on my device, maybe Sammy, LG only?) are different although the cause may be related... Guess we need more testing here since https://github.com/topjohnwu/libsu/pull/140

Dusk-Golem commented 1 year ago

@pndwal @DarkKnight1995 Hey guys, the issue and fix has been found, checkout the latest discussion of #6257. It will be in the next magisk-release build I suppose.

This issue and yours (doesn't occur on my device, maybe Sammy, LG only?) are different although the cause may be related... Guess we need more testing here since topjohnwu/libsu#140

I noticed another thing while trying to hide the latest debug build [831a398b (25206)]. The shortcut is created without issue but magisk app itself is not hidden and pressing on the shortcut results in App crash or app not responding errors. This happens if the wifi is turned off on the phone. If I try to hide when wifi is on, the process completes without any error.

Unfortunately this was a once time incident only since I was not able to reproduce this again (and I forgot to collect logs, fuck).

osm0sis commented 1 year ago

25205 was the last build where hiding worked correctly for me, can you try it? It's broken again currently so hopefully when that's fixed it'll work again for you.

Follow #6654 in the meantime.

Dusk-Golem commented 1 year ago

25205 was the last build where hiding worked correctly for me, can you try it? It's broken again currently so hopefully when that's fixed it'll work again for you.

Follow #6654 in the meantime.

Yes, I am using that build. Working fine.

osm0sis commented 1 year ago

Perfect. I'll mark this particular issue resolved then.

pndwal commented 1 year ago

Perfect. I'll mark this particular issue resolved then.

Why do you think it's resolved?

I've just had the same symptoms moving back to Canary 25206 app (ie.app asking for su permission, dual apps remaining...) https://github.com/topjohnwu/Magisk/issues/6654#issuecomment-1450263736 ...

Often, hiding will work fine with one attempt but fail with another...

The thing is, issues can be fixed by uninstalling duplicated apps w/ 25206 etc, so hidden App can still 'work fine' despite broken hiding routine... W/ new 25208 issue it seems nothing resolves it short of downgrading...

osm0sis commented 1 year ago

Because the creator of this issue says it works in 25205, so this issue is closed.

25208 has its own new hiding issue, which will be solved in the other open issue. No point in duplicated/stale issues.

pndwal commented 1 year ago

Because the creator of this issue says it works in 25205, so this issue is closed.

25208 has its own new hiding issue, which will be solved in the other open issue. No point in duplicated/stale issues.

Well it's not a stale issue and it is quite different to 25208 problem! 😜

I was very pleased to see this opened as it actually goes back at least as far as big 22.0 app hiding changes... I've been fielding basically the same issue regularly in XDA Magisk General Discussion thread since...

And, as I've said, it persists in 25206...

The nature of the issue means a user can't simply say 'it's fixed' without several hiding/unhiding attempts as it's not the hidden app that's failing, it's the hiding/unhiding process... As far as I can see, @DarkKnight1995 may simply have meant 25205 hidden App is working fine ATM... He did state:

this failure to hide and restore occurs randomly. When the app fails to hide or restore the itself and then you try to do the same (hide or restore) immediately after the failure then it works normally.

And he's actually reverted to 25205 having had issues even with Debug 25206 hiding!

Really, the issue titte should read/have been charged to 'Hiding and Restoring Magisk App not consistently working properly on many devices', but I doubt it was really fixed in 25205 even for Galaxy A8 2018 on Android 9...

Clearly the 25208 issue is more pressing/serious as the only workaround involves downgrading the app (which is fraught due to forceable downgrade prevention) to re-hide... Workaround for this issue is simply to locate the app Magisk failed to uninstall and do that manually...

Also, a fix for 25208 may foreseeably address both issues.

My feeling is that this issue should have been broadened and left open, but I'll wait to see how 25208 issue is resolved... If hiding/unhiding still fails to work consistently and this isn't re-opened after that I may make a fresh issue then... 🙃

osm0sis commented 1 year ago

🤷‍♂️

pndwal commented 1 year ago

🤷‍♂️

Good stuff, and thanks!... Hope 25209 release may resolve this along with 25208 issue...

pndwal commented 1 year ago

Sadly I can confirm that this issue still isn't fixed in 25209. (Please re-open it)...

I wasn't able to update App with or without it hidden from 25206, so uninstalled that and installed 25209 manually after which I took Hide the Magisk app...

On the first attempt I got this:

IMG_20230303_174354

As usual I ignored the message, closed the open App and after checking see that both full App and stub are installed... Stub data has in fact had data properly populated w/ Magisk binaries and after simply uninstalling he full App the hidden App works fine...

As before, Hide the Magisk app routine is simply failing to uninstall the full App after installing stub and populating it's data...

Also, as noted above, this is an inconsistent issue... With several subsequent attempts hiding succeeds without intervention, and with other attempts fails as described above...

pndwal commented 1 year ago

Also interesting is that as with 25208, stub version (now v35) no longer shows when App is hidden using stub... I'm not sure if this is an intended change...

AllenChangMusic commented 1 year ago

It's to the point now where if I try and install one of the artifacts, it will self uninstall on me, so the app doesn't even open... Not sure if the fixes to this are making things worse? I'm on A14 DP1 P7P

yujincheng08 commented 1 year ago

There's a race condiction when the release version of magisk is installing the hidden apk as root.

pndwal commented 1 year ago

It's to the point now where if I try and install one of the artifacts, it will self uninstall on me, so the app doesn't even open... Not sure if the fixes to this are making things worse? I'm on A14 DP1 P7P

Intended behaviour due to certificate checking... You need to install Debug build to bypass this (or fully uninstall Magisk) before installing a CI build... See https://github.com/topjohnwu/Magisk#signing-and-distribution

yujincheng08 commented 1 year ago

Should have been fixed by https://github.com/topjohnwu/Magisk/commit/a1ce6f5f120b1ce61d567cbd1f89d66cd5cf36a2

Plz chk.

pndwal commented 1 year ago

Many thanks for your efforts with this...

Strangely there's still an issue but now it may resolve itself...

Updating the app while hidden to 25210 went fine (apart from the extra Momo detections 😉)...

Next I took Restore the Magisk app, then Hide the Magisk app, and all app handovers went fine for four cycles...

On the fifth attempt to Hide the Magisk app, the app didn't reappear, so I found and opened the hidden stub app but Zygisk = No shows: IMG_20230307_020342

Next I looked for and found a full app (hadn't been removed) and it failed to detect Magisk: IMG_20230307_020228

I closed the full app and opened the hidden stub app again, and was very surprised to see Magisk and Zygisk detected properly... I had not removed the full app as required previously: IMG_20230307_020510

I then looked again for the full app and was surprised to find that it had now vanished!... Seems the hiding process had somehow frozen, and later decided to complete!? 🤔 ... So there was no need to intervene, but the delayed app removal is a puzzle...

Previously when a hide/restore process didn't finish I've had to manually uninstall a conflicting app...

Also, we previously saw the stub version, eg (34), shown.

Hope this assists your analysis...

Dusk-Golem commented 1 year ago

Because the creator of this issue says it works in 25205, so this issue is closed.

25208 has its own new hiding issue, which will be solved in the other open issue. No point in duplicated/stale issues.

Extremely sorry for the misleading info mate. I meant the debug build of 25205 (my bad). I haven't tried the later canary builds because of the hasle of going back and forth. Also I wasn't able to follow up because of some personal issue (life's been hard). Hope this clears it, issue is still there and it looks like this is not the case for just me.

yujincheng08 commented 1 year ago

This issue should have been fixed. If anyone has issues with hiding Magisk App, they should be different issues. Feel free to open a new issue with logs.