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: TikTok: Failed to apply patches: Dependency errors with 'Settings' causing multiple failures #525

Closed
3 tasks done
54m4d opened this issue Aug 4, 2023 · 25 comments
Closed
3 tasks done
Labels
Bug report Something isn't working

Comments

@54m4d
Copy link

54m4d commented Aug 4, 2023

Type

Error while patching

Bug description

Getting this error while patching TikTok 30.7.2

Steps to reproduce

Just try to patch TikTok as any other app.

Relevant log output

Initializing installer
Creating working directory
Copying original apk
Unpacking input apk
Reading dex files
Decoding AndroidManifest.xml only, because resources are not needed
Merging integrations
An error occurred! Aborted
Error:
java.lang.OutOfMemoryError: Failed to allocate a 32 byte allocation with 4005744 free bytes and 3911KB until OOM, target footprint 536870912, growth limit 536870912; giving up on allocation because <1% of heap free after GC.
	at java.util.LinkedHashMap.newNode(LinkedHashMap.java:280)
	at java.util.HashMap.putVal(HashMap.java:641)
	at java.util.HashMap.put(HashMap.java:611)
	at brut.androlib.res.data.ResType.addResource(ResType.java:49)
	at brut.androlib.res.data.ResType.addResource(ResType.java:44)
	at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:363)
	at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:308)
	at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:223)
	at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:132)
	at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:84)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:50)
	at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:778)
	at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:66)
	at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:58)
	at brut.androlib.Androlib.getResTable(Androlib.java:74)
	at app.revanced.patcher.Patcher.decodeResources(Patcher.kt:204)
	at app.revanced.patcher.Patcher.access$decodeResources(Patcher.kt:38)
	at app.revanced.patcher.Patcher$executePatches$1.invokeSuspend(Patcher.kt:351)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlin.sequences.SequenceBuilderIterator.hasNext(SequenceBuilder.kt:129)
	at app.revanced.manager.flutter.MainActivity.runPatcher$lambda-32(MainActivity.kt:395)
	at app.revanced.manager.flutter.MainActivity.$r8$lambda$efRWk2Z7aIFbIqnpE9hv8LpAiuk(Unknown Source:0)
	at app.revanced.manager.flutter.MainActivity$$ExternalSyntheticLambda13.run(Unknown Source:24)
	at java.lang.Thread.run(Thread.java:1012)

Screenshots or videos

N/A

Solution

N/A

Additional context

No special context.

Invalidly closing the issue is not acceptable.

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.
@54m4d 54m4d added the Bug report Something isn't working label Aug 4, 2023
@BrianPurgert
Copy link

I get the same error I've tried a couple different versions of TikTok

@LisoUseInAIKyrios
Copy link
Contributor

LisoUseInAIKyrios commented Aug 4, 2023

Are you patching with Manager, or with command line tools?

Edit: the stack trace shows it's Flutter, so it's patched with Manager.

@54m4d
Copy link
Author

54m4d commented Aug 4, 2023

Manager v1.6.1

I've never succeeded in patching TikTok before, even with older Manager/TikTok versions, but today i decided to open the issue.

@LisoUseInAIKyrios
Copy link
Contributor

File a bug report in Manager repository, it might be an issue with Manager not allocating enough memory to the patcher. Or there's a chance it's something going haywire during the patcher decoding and it's blowing out the device memory limit.

For now you can patch using command line tools, but you'll probably also have to include the -Xmx flag with a max memory value (ie: -Xmx2048M)

@54m4d
Copy link
Author

54m4d commented Aug 4, 2023

I saw this comment there, so prolly not a Manager issue if that person is right.

@io43
Copy link

io43 commented Aug 5, 2023

yea it don't work with manager android13- pixel5 6gb ram , have to use the cli with revanced-patches jar and revanced-integrations apk instead, make sure to use an other java version (i'm using openjdk-18) if you see the error

org.bouncycastle.jcajce.provider.keystore.bc.BcKeyStoreSpi$BCKeyStoreException: java.io.IOException: Error initialising store of key store: java.lang.SecurityException: JCE cannot authenticate the provider BC

while signing the apk with the cli

@karx1
Copy link

karx1 commented Aug 7, 2023

Hi, I solved it by using the CLI, you can read this Reddit thread for a guide

@54m4d
Copy link
Author

54m4d commented Aug 7, 2023

I'm a Manager user.

@LisoUseInAIKyrios
Copy link
Contributor

This issue should be moved to Manager repository. This issue only shows up when patching with Manager.

Manager already has android:largeHeap="true" set.

But perhaps the Flutter/Dart settings can be adjusted? I've never used Flutter or Dart so I can't comment on this much.
Maybe this is the fix?

@Axelen123
Copy link
Member

Axelen123 commented Aug 7, 2023

This issue should be moved to Manager repository. This issue only shows up when patching with Manager.

Manager already has android:largeHeap="true" set.

But perhaps the Flutter/Dart settings can be adjusted? I've never used Flutter or Dart so I can't comment on this much. Maybe this is the fix?

I don't think anything can be done. The problem is caused by the Android runtime not giving us enough java heap memory. Dart memory allocations don't contribute to that limit if I understand things correctly. People who run into this have to use the CLI in Termux instead, which does not have this memory limit.

@LisoUseInAIKyrios
Copy link
Contributor

The OOM stack trace here shows the max heap is set to a modest 512MB (some users have shown OOM at 256MB), which seems small if the maxheap flag is being applied to the patching process.

If Dart does not contribute to the heap memory of the android app, then it must be running on its own process/service or some other memory isolation. That means it might be possible to increase the max memory of that process/service.

If this truly cannot be fixed, then maybe the OOM can be caught and the user informed that Manager won't work and CLI is required.

@54m4d
Copy link
Author

54m4d commented Aug 7, 2023

  1. You guys need to agree if this is a Manager issue or not, as you may have seen, oSumAtrIX mentioned that it's not related to the Manager, but at least they gave a comment before closing that issue.

  2. If CLI is the only way to patch this, TikTok patches may be temporarily or permanently disabled in the Manager, with users being informed to use the CLI instead, in order to avoid confusion.

@oSumAtrIX
Copy link
Member

There is no such thing as "Disabling" patches. TikTok can be patched on ReVanced Manager if you have enough memory, but the issue is inherently large memory usage due to dexlib2. ReVanced Manager can fix it by increasing max memory usage.

@54m4d
Copy link
Author

54m4d commented Aug 8, 2023

Fixed in Manager v1.7.0

@54m4d 54m4d closed this as completed Aug 8, 2023
@LisoUseInAIKyrios
Copy link
Contributor

Not sure how it was fixed when 1.7.0 has no patcher or memory related changes, but oh well 🤷🏼‍♂️

@Axelen123
Copy link
Member

Axelen123 commented Aug 8, 2023

There is no such thing as "Disabling" patches. TikTok can be patched on ReVanced Manager if you have enough memory, but the issue is inherently large memory usage due to dexlib2. ReVanced Manager can fix it by increasing max memory usage.

We already did and its still not enough for some devices

@54m4d
Copy link
Author

54m4d commented Aug 8, 2023

I have tried the exact same process i tried with the previous Manager and i got no issues now, i have also tested with the version of TikTok where this issue appeared and i got no memory errors, It's fair to say Manager v1.7.0 fixed the memory issue.

@LisoUseInAIKyrios
Copy link
Contributor

When patching using Termux, it doesn't have these memory limitations. And it's a regular android app, and it even has the memory overhead of running a full Linux system (which surely uses more memory than the ReVanced Manager UI).

Yet Termux has no OOM problems. For reference, Java command line in Termux shows a max heap memory of 1.8GB. Meanwhile the patcher in Flutter Manager is blowing out at 256 or 512MB.

@Axelen123
Copy link
Member

Axelen123 commented Aug 8, 2023

Termux does not run an entire operating system. It just launches linux processes. Only dalvik code running in ART is subjected to the problematic java heap limit. It does not apply when running the JRE in Termux.

@54m4d
Copy link
Author

54m4d commented Aug 8, 2023

I believe i spoke a bit too soon. When i tried an older version of TikTok, i encountered a different error unrelated to memory issues.

The suggested version of Tiktok for patching should not be set as "All," as some versions work just fine, like 30.7.4 while others can throw errors like the one below, re-opening this issue since ReVanced Patches do not work properly with TikTok.

Initializing installer
Creating working directory
Copying original apk
Unpacking input apk
Reading dex files
Decoding AndroidManifest.xml only, because resources are not needed
Merging integrations
Executing patches
Failed to apply Downloads: 'Downloads' depends on 'Settings' but the following error was raised: Failed to resolve SettingsEntryFingerprint
Failed to apply Feed filter: 'Feed filter' depends on 'Settings' but the following error was raised: 'Settings' did not succeed previously
Applied Hide ads
Failed to apply Playback speed: NullPointerException
Failed to apply Settings: 'Settings' did not succeed previously
Failed to apply Sim spoof: 'Sim spoof' depends on 'Settings' but the following error was raised: 'Settings' did not succeed previously
Repacking patched apk
Not compiling resources because resource patching is not required
Writing modified dex files
Finished!

@54m4d 54m4d reopened this Aug 8, 2023
@54m4d 54m4d changed the title bug: TikTok OutOfMemoryError While Patching. bug: TikTok: Failed to apply patches: Dependency errors with 'Settings' causing multiple failures Aug 8, 2023
@oSumAtrIX
Copy link
Member

This is not a patch issue. There is simply not enough RAM provided to patch the app on your end.

@oSumAtrIX oSumAtrIX closed this as not planned Won't fix, can't repro, duplicate, stale Aug 9, 2023
@54m4d
Copy link
Author

54m4d commented Aug 9, 2023

So enough RAM is only provided to certain TikTok apks but not others, is that what you are trying to say?

In the last error, how can you tell if enough RAM was not provided?

@oSumAtrIX
Copy link
Member

Enough RAM is needed to patch TikTok. The last error is a product of patching an old version.

@54m4d
Copy link
Author

54m4d commented Aug 9, 2023

Forget the memory issue now, it has been addressed in Manager v1.7.0. and i tested and got no memory errors.

The last issue is not related to memory and the suggested version of Tiktok for patching is set to"All," so i don't understand why you mention "old version"? read my posts once again, you seem like you have a hard time distinguishing between a memory issue and something else, please re-open this issue.

@Axelen123 Can you confirm if this is a Manager issue or not?

@Axelen123
Copy link
Member

Axelen123 commented Aug 9, 2023

Can you confirm if this is a Manager issue or not?

Long answer:
The memory issue is caused by the android app runtime (ART) not giving the patcher enough java heap memory. The only way to affect how much memory you are provided is to set the android:largeHeap attribute in the manifest, but we have already done that. The CLI is unaffected because it does not run in ART unlike manager.

Short answer: I would say this is a manager issue, but we cannot do anything about it.

If you are having another problem then you need to open a new issue so it can be tracked properly.

@oSumAtrIX oSumAtrIX transferred this issue from ReVanced/revanced-patches-template Dec 14, 2023
@revanced-bot revanced-bot transferred this issue from another repository Dec 14, 2023
taylorkline added a commit to taylorkline/revanced-manager that referenced this issue Apr 16, 2024
Patching large applications (e.g. TikTok) on Android with multithreading simply doesn't work on multicore devices where the amount of memory given to the manager (regardless of the system RAM) is not sufficient.

It's more important that patching succeeds for all available use cases than for only some patching to succeed with faster performance. A UI option can be added later, but the multithreading option should be opt-out by default rather than opt-in.

Closes ReVanced/revanced-documentation#35
Closes ReVanced#1454
Closes ReVanced#1571
Closes ReVanced#1595
Closes ReVanced#1659
Closes ReVanced#1661
Closes ReVanced#1684
Closes ReVanced#1759
Closes ReVanced#1802
Closes ReVanced#1817
Closes ReVanced/revanced-manager#2885
Closes ReVanced#592
Closes ReVanced/revanced-patcher#193
Closes ReVanced/revanced-patches#1533
Closes ReVanced/revanced-patches#1608
Closes ReVanced/revanced-patches#1613
Closes ReVanced/revanced-patches#1630
Closes ReVanced/revanced-patches#190
Closes ReVanced/revanced-patches#2511
Closes ReVanced/revanced-patches#525
taylorkline added a commit to taylorkline/revanced-manager that referenced this issue Apr 16, 2024
Patching large applications (e.g. TikTok) on Android with multithreading simply doesn't work on multicore devices where the amount of memory given to the manager (regardless of the system RAM) is not sufficient.

It's more important that patching succeeds for all available use cases than for only some patching to succeed with faster performance. A UI option can be added later, but the multithreading option should be opt-out by default rather than opt-in.

Closes ReVanced/revanced-documentation#35
Closes ReVanced#1454
Closes ReVanced#1571
Closes ReVanced#1595
Closes ReVanced#1659
Closes ReVanced#1661
Closes ReVanced#1684
Closes ReVanced#1759
Closes ReVanced#1802
Closes ReVanced#1817
Closes ReVanced/revanced-patches#2885
Closes ReVanced#592
Closes ReVanced/revanced-patcher#193
Closes ReVanced/revanced-patches#1533
Closes ReVanced/revanced-patches#1608
Closes ReVanced/revanced-patches#1613
Closes ReVanced/revanced-patches#1630
Closes ReVanced/revanced-patches#190
Closes ReVanced/revanced-patches#2511
Closes ReVanced/revanced-patches#525
taylorkline added a commit to taylorkline/revanced-manager that referenced this issue Apr 16, 2024
Patching large applications (e.g. TikTok) on Android with multithreading simply doesn't work on multicore devices where the amount of memory given to the manager (regardless of the system RAM) is not sufficient.

It's more important that patching succeeds for all available use cases than for only some patching to succeed with faster performance. A UI option can be added later, but the multithreading option should be opt-out by default rather than opt-in.

Closes ReVanced/revanced-documentation#35
Closes ReVanced#1454
Closes ReVanced#1571
Closes ReVanced#1595
Closes ReVanced#1659
Closes ReVanced#1661
Closes ReVanced#1684
Closes ReVanced#1759
Closes ReVanced#1802
Closes ReVanced#1817
Closes ReVanced/revanced-patches#2885
Closes ReVanced#592
Closes ReVanced/revanced-patcher#193
Closes ReVanced/revanced-patches#1533
Closes ReVanced/revanced-patches#1608
Closes ReVanced/revanced-patches#1613
Closes ReVanced/revanced-patches#1630
Closes ReVanced/revanced-patches#190
Closes ReVanced/revanced-patches#2511
Closes ReVanced/revanced-patches#525
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

Successfully merging a pull request may close this issue.

7 participants