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

feat: Ability to handle load failures with multiple bundles

Open Axelen123 opened this issue 2 months ago • 8 comments

Feature description

Refer to title and motivation.

Motivation

The loadPatchesFromDex/Jar function loads all bundles in the provided set. Any exception during the loading process will result in successfully loaded/loadable patches to be lost. A way to solve this while still allowing cross bundle patch dependencies is shown here.

Acknowledgements

  • [x] I have checked all open and closed feature requests and this is not a duplicate.
  • [x] I have chosen an appropriate title.
  • [x] All requested information has been provided properly.

Axelen123 avatar Oct 11 '25 10:10 Axelen123

Do we load each patch class in its own classloader? This would be even more fine grained and would allow bi directional cross dependencies

oSumAtrIX avatar Oct 11 '25 12:10 oSumAtrIX

One major issue with that approach is when multiple patches use a shared utils class or something. That class would either have to be loaded individually for each patch class or need its own classloader. Both options don't seem great in terms of memory usage.

Axelen123 avatar Oct 11 '25 13:10 Axelen123

Class loading is delegated to the parent, so they should both resolve to a common classloader

oSumAtrIX avatar Oct 11 '25 13:10 oSumAtrIX

Now that I think about it, wouldn't it be enough to simply catch exceptions here instead of propagating them? The caller could handle them through a lambda or something.

This would be much simpler than managing multiple classloaders.

Axelen123 avatar Oct 11 '25 14:10 Axelen123

I think that could work. runCatching { loadClass() } an use mapNotNull

oSumAtrIX avatar Oct 11 '25 14:10 oSumAtrIX

Can you PR this? Should be simple

oSumAtrIX avatar Oct 11 '25 14:10 oSumAtrIX

Maybe it should append errors to a list passed to the loader function?

oSumAtrIX avatar Oct 11 '25 14:10 oSumAtrIX

I am going to be busy for a few weeks now. Don't know when I have time to do it.

Axelen123 avatar Oct 13 '25 19:10 Axelen123