Closed Sculas closed 2 years ago
I may have to declare this a wontfix. I'm currently writing the custom implementation of getCommonSuperClass
and it seems we also need to load the entire Android API into memory. This implementation already uses a lot of memory, so I think the only way out is to write stack frames yourself. Fixing this issue won't help #14 in any way.
Work is being done in fix/classwriter. This is a wontfix for now.
This has been "fixed" in https://github.com/ReVancedTeam/revanced-patcher/commit/c8a017a4c0a659e8450df24e56bfcb90cb0739bd. You have to write stack frames yourself if you modify the stack. I'm going to add helper methods for this.
:tada: This issue has been resolved in version 1.0.0-dev.9 :tada:
The release is available on:
v1.0.0-dev.9
Your semantic-release bot :package::rocket:
To reproduce this issue, please download the stock YouTube app from any source of your choice. I recommend the Vanced Codebucket mirror. Use dex2jar to convert the APK to JAR. Then run this code:
This will fail with this error:
This exception is thrown because the standard implementation of
getCommonSuperClass
inClassWriter
uses the systemClassLoader
to find said class to get the type out of it (it will invokeType#getType(Class<?> clazz)
).This issue can be mitigated by telling setting the
mode
toCOMPUTE_MAXS
instead ofCOMPUTE_FRAMES
. But this will not work when adding branches (afaik) because only the local vars are computed, and new frames for each branch are not. This means you need to add the stack frame yourself if you patch the code. Since the patcher is also meant as a general-use library, we should not rely on the experience of the developers to write stack frames themselves. We should really fix this issue instead. I'm not yet sure how to test this, I will have to look into adding tests for this case.The intended solution for this is to make our own
ClassWriter
implementation and override thegetCommonSuperClass
to use our class cache and get the types out of that. Note that computing frames is really expensive and will take up some CPU and memory.