Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: When patching fails you're stuck with a broken YT app on every reboot even when reinstalling stock and/or uninstalling manager #425

Closed
4 tasks done
Nodens- opened this issue Oct 22, 2022 · 15 comments
Labels
Bug report Something isn't working

Comments

@Nodens-
Copy link

Nodens- commented Oct 22, 2022

Type

Other

Bug description

I tried a few patches on the latest supported version on my device (rooted method without microg). I eventually found a combination that worked. After a restore to stock and trying a different patch combination it started crashing and my original patch combination was also not working anymore. After reboot Youtube app kept crashing even when restored to stock prior to reboot, to my surprise. I kept uninstalling and reinstalling a clean version and always on reboot it would be replaced with a non-working version.

I went ahead and cleaned the tmp directory from within the app. No effect.
Then I uninstalled the manager and again no effect. Always on reboot the working version would be replaced with a non working one.

I finally started digging around to debug and I figured out what was happening. There are some scripts installed that run on boot and replace the installed version with the patched version. I assume this is done in order to workaround auto app upgrade. BUT, there are several issues at play here.

  1. For some reason the file written on the tmp directory was not being replaced, so no matter how I patched again I was always getting the same broken version.
  2. Deleting the tmp directory from the manager had no effect as well. Both .apk files were still there. (This points to a write error? Permissions?)
  3. Uninstalling the manager, leaves the replace script in place, in both locations, which means that an unsuspecting user, one that can't debug this by looking at the code, is absolutely stuck with a broken youtube app every time they reboot the device.

I believe #237 is also related in part to this.

Steps to reproduce

Not sure if this is 100% reproducible (the write/delete tmp directory part) or something that triggers intermittently.
In my case it was always impossible to delete the tmp directory from the manager and uninstalling always left the script in both locations and the tmp directory in place.

Android version

12

Manager version

0.0.36

Target package name

Youtube

Target package version.

17.36.37

Installation type

Root

Patches selected.

I tried several patch combinations. I got it to work with just background and the 2 ad patches but it was after trying different combination of patches (that I can't remember right now) and getting a crashing youtube app, that I couldn't get the original 3 patch combo to work either and ending with an always broken version replacement on reboot.

Device logs (exported using Manager settings).

Did not manage to save logs as I started debugging this after uninstalling and figuring out that I still get a broken app replacement on reboot.

Installer logs (exported using Installer menu option) [unneeded if issue is not during patching].

No response

Screenshots or videos

No response

Solution

Manually delete revanced files in /data/local/tmp, in /data/adb/service.d and in /data/adb/post-fs-data.d to recover.

Additional context

No response

Acknowledgements

  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly.
  • The issue is related solely to the ReVanced Manager
@Nodens- Nodens- added the Bug report Something isn't working label Oct 22, 2022
@ayZagen
Copy link

ayZagen commented Oct 23, 2022

This is the same thing happened to me but the solution you have mentioned is not working at all. Clearing those folders has no effect. Reinstalling youtube not working too.

I have installed the app using root method maybe that's why your solution didn't work for me.

Clearly this is a bug.

@Nodens-
Copy link
Author

Nodens- commented Oct 24, 2022

You probably missed it but I also use the root method. Perhaps there is a third script in your case or you did not remove the proper files.

@Kavindu-Deshapriya
Copy link

In my case I patched YouTube successfully but after some days YouTube app is renamed to "Apply" and can't start the app

@RKPlane
Copy link

RKPlane commented Nov 3, 2022

I fixed this by a clunky method, basically the revanced manager installs a broken YT app at system startup (in my case Twitter and Reddit too) so instead of updating or uninstalling it, I disabled signature verification in the package manager (Lucky patcher method with Xposed settings), then install on top of the modded one the official one and that fixed both Twitter and Reddit, for YouTube I only update in Google play and starts working again.

Good luck trying my method

PD: Manager should have an option to undo that startup script I hope OP reads this it's annoying to deal with this every startup.

@ipdev99
Copy link

ipdev99 commented Nov 5, 2022

A little history..

A few years ago, due to updates in Android security, modified versions of apk files would fail verification on boot.
You could adjust the permissions, owner/group, security, .. but, no guarantee it would survive verification.
What works on one device might fail on another.
The only sure way was to compromise device security by disabling the verification.

Instead, we can use the mount command to overlay the modified version.
Work around the security instead of disabling it.

This allows the stock version to be found and verified on boot.
Once verified, we can then overlay the modified version.

This is what the boot script(s) are for.


When you use the patcher app to install the root version.
It will create a modified apk file with the patch(s) you selected.

The permissions of the modified apk file needs to be set correctly.
This can not be done in a normal user level like /sdcard/ so /data/local/tmp is used since it has heighten permission levels.

Note:
Vanced used Magisk's /data/adb/ directory.
Seems ReVanced might follow suit. - commit


In my testing, I found I have to include the Client Spoof patch for YouTube.
I am not sure if it is required for every device/system but, for me, it fails when I do not include that patch.

Cheers. 🤠

PS:
I am using the "root" method but, I do not use the ReVanced script(s) or install.
I use my own script(s) and a slightly different way to install. 🙃

@Nodens-
Copy link
Author

Nodens- commented Nov 12, 2022

I understand perfectly why the scripts are there, although I don't actually need that method as I'm patching android for other reasons. The problem here though is that the Manager does not cleanup. Neither the tmp directory or the scripts on uninstall. There's also an issue with overwriting the files in the tmp directory that along with inability to clean, leaves you completely stuck with a broken app if you can't figure out how it's implemented in order to manually clean it. And the vast majority of users fall into that category.
Ideally the root method should just switch to a magisk module.

@bassmadrigal
Copy link

Due to the issues I have documented in #519, I have to "fix" a broken so frequently. I've found the only way to guarantee proper startup is to clear the app data and "uninstall updates" for YouTube in the Play Store. After that, I'm back to a completely stock YouTube with all settings reverted to their original values as if you first opened YouTube.

From there, I'm able to upgrade YouTube to my preferred version and then use ReVanced Manager to patch it.

This will work until my device is rebooted again, then I have to do the above all over again. I have not needed to go into /data/ and manually delete anything.

Maybe it'll work for you as well. Good luck!

@Nodens-
Copy link
Author

Nodens- commented Dec 2, 2022

@bassmadrigal it's exactly because you have not manually deleted anything coupled with the issue reported here that you have to redo everything after reboot. This IS the actual issue reported which you have not understood.

A broken patched version is being copied from /data/local/tmp over your working patched version (and even over the stock unpatched one) on every reboot by the scripts installed in /data/adb/service.d and /data/adb/post-fs-data.d which is forcing you to redo everything after reboot. Is it more clear now?

Manually deleting the broken version from /data/local/tmp will prevent the overwrite and removing the 2 scripts will clear the copy on boot behavior entirely.

@bassmadrigal
Copy link

@Nodens- This happened on two different devices months apart from each other with the exact same symptoms. I've only had my Pixel 7 for a month and ReVanced was a brand new install on a freshly rooted device (ie, those folders and files would've been empty/non-existent).

The issue also existed previously with my Pixel 6 with both revanced-cli (which I used before the Manager was released) and ReVanced Manager.

And if this is the problem, why isn't ReVanced Manager clearing those folders/files as well and replacing them with non-broken versions?


BTW, looking into those folders, my /data/local/tmp files are from yesterday. Are you saying that ReVanced Manager is still making broken apks and installing scripts that install those broken apks after every reboot or that I have older versions that were broken that modern installs don't have to deal with?

Either way, this is looking like a ReVanced bug and shouldn't require manually deleting anything.

@Nodens-
Copy link
Author

Nodens- commented Dec 3, 2022

There are at least 2 different interrelated issues. First is that Revanced Manager doesn't clean either the scripts and the patched files from tmp on uninstall or the patched files from tmp on the delete temp files option. And the second is that something is preventing the Manager from writing properly in the tmp directory so the files there are broken and the scripts keep overwriting your youtube even if you uninstall Revanced Manager. Could be SELinux related, I didn't investigate further. But yes it is a bug.

If you want as a workaround to stop redoing patches at reboot, do this:
Patch with the manager properly so you have a working patched youtube.
Uninstall the manager
Delete the files from tmp and the 2 scripts.
Tada no more broken youtube on reboots.

EDIT: Forgot to mention but if you missed it, read ipdev99's comment above regarding why the scripts and the copy on boot implementation is there to begin with.

@bassmadrigal
Copy link

bassmadrigal commented Jan 3, 2023

If you want as a workaround to stop redoing patches at reboot, do this: Patch with the manager properly so you have a working patched youtube. Uninstall the manager Delete the files from tmp and the 2 scripts. Tada no more broken youtube on reboots.

This did not work (edit, or I we misunderstood each other and what I wanted to happen after a reboot). This reverted YouTube back to the stock version on reboot.

There was a benefit to this method in that the stock version that shows up on reboot (which I wanted to be ReVanced) did not crash when trying to open it up. And when reinstalling ReVanced Manager and repatching YouTube, all my custom settings were retained.

This doesn't surprise me knowing the basics behind how systemless changes work to retain SafetyNet approval, which I get into below.

EDIT: Forgot to mention but if you missed it, read ipdev99's comment above regarding why the scripts and the copy on boot implementation is there to begin with.

How would ReVanced survive a reboot if you're removing the scripts that overwrite the stock YouTube after initial checks occur during boot?

This is what they wrote:

This allows the stock version to be found and verified on boot.
Once verified, we can then overlay the modified version.

This is what the boot script(s) are for.

Removing those scripts would then prevent the ReVanced version from overlaying the stock version on bootup.

@ipdev99
Copy link

ipdev99 commented Jan 4, 2023

This did not work (edit, or I we misunderstood each other and what I wanted to happen after a reboot). This reverted YouTube back to the stock version on reboot.
This is what they wrote:

This allows the stock version to be found and verified on boot.
Once verified, we can then overlay the modified version.

This is what the boot script(s) are for.

Removing those scripts would then prevent the ReVanced version from overlaying the stock version on bootup.

The problems seems to be the prevoius files are not being replaced by the new version(s).

To overcome this you need to remove (delete) the current boot scripts and patched version before you patch and install again using the Manager.
You might want to clear data and cache of the Magnager app also before patching.

This should give your device a clean slate and the new scripts will be written and the patched apk file place properly.

Example YouTube:
Remove the boot scripts.
/data/adb/post-fs-data.d/com.google.android.youtube.sh
/data/adb/service.d/com.google.android.youtube.sh

Remove the ReVanced YouTube mount directory.
/data/local/tmp/revanced-manager/com.google.android.youtube

Then use ReVanced Manager to patch and install as root again. 😉

Hope it helps more than confuse. 🙃

🤠

@bassmadrigal
Copy link

I had already done that and that's what reverted YouTube to the stock version after a reboot instead of the patched ReVanced version I had just installed.

To give you the rundown, to prep, I deleted the boot scripts, the revanced-manager/com.google.android.youtube folders, ReVanced Manager, and reverted YouTube back to stock (uninstalled updates, cleared data, then reinstalled/upgraded the stock YouTube to 17.49.37 with the apk).

Then I rebooted, installed ReVanced Manager, patched YouTube, then removed the boot scripts, the revanced-manager/com.google.android.youtube folders, and ReVanced Manager. Rebooted and I was greeted with the stock YouTube.

Reinstalled ReVanced Manager, patched again, rebooted without deleting those newly generated scripts and apks, and YouTube crashes on opening and I have to uninstall updates and clear data to allow me to open YouTube again (which I then need to patch and reset all my settings).


There is one good thing I've found through this testing and that's to delete the scripts and folder before rebooting, because then I just need to repatch to get ReVanced back but my YouTube settings (both stock and ReVanced) stay untouched. It sucks needing to reset them every time you reboot your phone.

@Nodens-
Copy link
Author

Nodens- commented Jan 17, 2023

Yeah this is why I said that this needs to be a magisk module. The current method is rather messy and it seems like something prevents proper writes causing all this. I didn't pursue debugging this as I have moved to using wanam's lsposed module which just works for what want it to do.

@Ushie Ushie linked a pull request Oct 25, 2023 that will close this issue
3 tasks
@oSumAtrIX
Copy link
Member

This should be fixed as the installation process is now separated from the patching process

@Ushie Ushie removed a link to a pull request Feb 11, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug report Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants