revanced-manager icon indicating copy to clipboard operation
revanced-manager copied to clipboard

Export APK button doesn't respond after Opening installed app

Open KobeW50 opened this issue 1 year ago • 8 comments

Bug description

After you install an app and open it (via the "Open" button), and then go back into the Manager and try to export the patched APK the export button will not work. All other buttons work except for the Back button, which is likely a different bug. (See https://github.com/ReVanced/revanced-manager/issues/1510)

Steps to reproduce

  1. Patch YT with the default patches
  2. Install the patched app using the "Install" button
  3. Open the installed app with the "Open" button
  4. Exit the patched app and go into the Manager
  5. Press the "Export APK" button on the bottom left

https://github.com/ReVanced/revanced-manager/assets/84587632/82ebd9bc-30f1-423f-903e-78ca6c621240

Version of ReVanced Manager and version & name of application you tried to patch

1.17.0 YT 18.45.41

Logs

The installation completed at 12:57:46 so the issue will be in the seconds shortly afterwards

https://drive.google.com/file/d/11q675aPBTo8XNUe2kK_TT3-DiOmQRq7x/view?usp=drivesdk

Installation type

Non-root

Device logs

Uploaded

Patcher logs

No response

Acknowledgements

  • [X] This request is not a duplicate of an existing issue.
  • [X] I have chosen an appropriate title.
  • [X] All requested information has been provided properly.
  • [X] The issue is solely related to the ReVanced Manager

KobeW50 avatar Nov 29 '23 18:11 KobeW50

Now when I open the installed app using the "Open" button and then return to the manager, the manager will reset to the dashboard tab which means this bug can't be reproduced atm. (This occurs even when the Manager stays open in pop-up view or split screen while the patched app is being opened.)

I guess this new behavior is a bug, and it masks the bug reported in this issue.

KobeW50 avatar Dec 20 '23 05:12 KobeW50

Now when I open the installed app using the "Open" button and then return to the manager, the manager will reset to the dashboard tab which means this bug can't be reproduced atm. (This occurs even when the Manager stays open in pop-up view or split screen while the patched app is being opened.)

I guess this new behavior is a bug, and it masks the bug reported in this issue.

Is the behavior of returning back to the dashboard not intended? This was added in the following commit. c5fc54e7 The installer page is popped after opening the installed app.

{
                          model.openApp(),
                          model.cleanPatcher(),
                          Navigator.of(context).pop(),
 }

And as for the export APK button, it seems to be not working right after installing the app irrespective of you opening it or not. The APK file is probably cleared from the cache as soon as the app is installed. Assuming this issue is still persisting, can I have a look at it?

pehchankon avatar Jan 15 '24 15:01 pehchankon

https://github.com/ReVanced/revanced-manager/blob/79114598173c3059ad3a1d9cc33708e095747d12/lib/ui/views/installer/installer_viewmodel.dart#L482

This line seems to be the root cause for invalidating the cache. Going deeper, HomeViewModel's initializer is calling the PatcherAPI's initializer which clears the cache.

Similarly, the cleanPatcher() method(again this clears the cache etc) is called after opening the installed app as I mentioned in my previous comment. This makes sense only if the intention is to go back to the dashboard after the user chooses to open the app. However, I'm not sure why HomeViewModel is initialized after the user installs the app.

pehchankon avatar Jan 15 '24 17:01 pehchankon

@pehchankon Iirc it is to refresh the list of installed apps on the dashboard

oSumAtrIX avatar Jan 15 '24 21:01 oSumAtrIX

@oSumAtrIX Yeah that seems to be the case. Instead of initializing the HomeViewModel again, can we directly refresh the list of installed apps by something like this?

await _managerAPI.reAssessSavedApps().then((_) => locator<HomeViewModel>().getPatchedApps());

Edit: The HomeViewModel already contains a getPatchedApps function, however its scope is private, I think it can be made public to tackle this issue.

pehchankon avatar Jan 16 '24 08:01 pehchankon

I had asked the same question in the past, and got an answer from @BenjaminHalko who said that other issues could be caused by that iirc. Maybe they can give an insight on that

oSumAtrIX avatar Jan 16 '24 11:01 oSumAtrIX

I think reassessing apps would not cause any issues. In fact I think I do it in #1414

BenjaminHalko avatar Jan 16 '24 15:01 BenjaminHalko

The question is not if reassessing apps causes any issues but if not reinitializing the home page. Last time I remember asking if it is necessary to do when changing the sources/API and related it to this case

oSumAtrIX avatar Jan 16 '24 15:01 oSumAtrIX