opa334 / Dopamine

Dopamine is a semi-untethered jailbreak for iOS 15 and 16
MIT License
3.35k stars 1.91k forks source link

Need help on userspace reboot issue #187

Closed bgli100 closed 1 year ago

bgli100 commented 1 year ago

Hi, I am porting permaflex (https://github.com/shiftcmdk/PermaFlex) to Dopamine (1.0.5), and encountered a userspace reboot issue.

Situation:

  1. Currently it works if no userspace reboot happen. When I install the tweak via theos/Sileo and it works after a respring.
  2. If an userspace reboot happens with tweak installed + tweak injection enabled, device stuck on apple logo for 1-2 minutes and eventually fully reboot.
  3. If tweak gets uninstalled and/or tweak injection disabled then userspace reboots work.

Need help on:

  1. Do you have idea of what could possibily go wrong? I guess the tweak might hooked something it shouldn't touch but can't figure out what it is.
  2. How can I diagnose this?

p.s. tried to print a log of hooked processes upon userspace reboot, here is what I got: com.opa334.Dopamine /var/containers/Bundle/Application//Dopamine.app/Dopamine <- this is when I pressed the userspace reboot button com.apple.springboard /System/Library/CoreServices/SpringBoard.app/SpringBoard com.apple.Preferences /Applications/Preferences.app/Preferences com.apple.springboard /System/Library/CoreServices/SpringBoard.app/SpringBoard com.apple.springboard /System/Library/CoreServices/SpringBoard.app/SpringBoard <- device reboots here

opa334 commented 1 year ago

Try commenting out all NSLog calls. If you try calling that inside logd itself it will make the process stuck. Other than that, no idea.

bgli100 commented 1 year ago

Try commenting out all NSLog calls. If you try calling that inside logd itself it will make the process stuck. Other than that, no idea.

Tried and it still not work :(

Found a few logs in settings, seems watchdog killed a few SpringBoards due to timeout, but the problem still present even I commented out everything it does inside SpringBoard (including NSlogs).

opa334 commented 1 year ago

https://github.com/shiftcmdk/PermaFlex/blob/master/Tweak.xm#L243-L245 Instead of these, use these https://github.com/opa334/Choicy/blob/master/Tweak.x#L40-L55

opa334 commented 1 year ago

Also I feel like this is only supposed to be called for SpringBoard but the logic is wrong and it will be called for everything that's an app https://github.com/shiftcmdk/PermaFlex/blob/master/Tweak.xm#L261

bgli100 commented 1 year ago

https://github.com/shiftcmdk/PermaFlex/blob/master/Tweak.xm#L243-L245 Instead of these, use these https://github.com/opa334/Choicy/blob/master/Tweak.x#L40-L55

Replaced with the safe variant but no lock :-(

P.S. My modifications were available via this fork: https://github.com/bgli100/PermaFlex

bgli100 commented 1 year ago

Also I feel like this is only supposed to be called for SpringBoard but the logic is wrong and it will be called for everything that's an app https://github.com/shiftcmdk/PermaFlex/blob/master/Tweak.xm#L261

It works correctly but it is bad code. I re-structured this part. The method initForSpringBoard checks bundle identifier again inside itself and runs if it is springboard. Redundent.

bgli100 commented 1 year ago

Update:

It seems SpringBoard is not related to the fault. I played with the .plist file and found if the tweak injects to any of the following 2 bundle, userspace reboot fails (not sure why, it fails when the tweak does not run anything):

com.apple.UIKit com.apple.security

But it works when injecting both com.apple.springboard and com.apple.AdSupport (which covers most cases since I use it to block in-app ads)

At least I have a partial fix now

opa334 commented 1 year ago

I will test this soon. You probably make some daemon lock up.

dollarystem commented 1 year ago

I had similar issue and this fixed it, please try and if it helps you Opa is going to finally fix this issue!!

1)Download and Install Xina 1.1.8 from TrollStore and Filza Trollstore edition and hit Jailbreak it will proccess it and it will work with Dopamine 2)You dont need Xina, Reboot, Go to Xina settings hit safe mode hit jailbreak 3)Now you can delete everything from /var/jb/Application!!!! in Filza but don't do it since there will be nothing because you are on Xina so 4)Go to /private/preboot/(YOUR SPECIAL ID)/jb-(some letters)/procursus/Application and delete every file inside there If you need TrollStore version of Sileo until Opa fixes it, I can give it to you and Zebra too

opa334 commented 1 year ago

I had similar issue and this fixed it, please try and if it helps you Opa is going to finally fix this issue!!

1)Download and Install Xina 1.1.8 from TrollStore and Filza Trollstore edition and hit Jailbreak it will proccess it and it will work with Dopamine 2)You dont need Xina, Reboot, Go to Xina settings hit safe mode hit jailbreak 3)Now you can delete everything from /var/jb/Application!!!! in Filza but don't do it since there will be nothing because you are on Xina so 4)Go to /private/preboot/(YOUR SPECIAL ID)/jb-(some letters)/procursus/Application and delete every file inside there If you need TrollStore version of Sileo until Opa fixes it, I can give it to you and Zebra too

you really want to get blocked, do you? your bs has NOTHING to do with this issue so keep it out of it please

dollarystem commented 1 year ago

I had similar issue and this fixed it, please try and if it helps you Opa is going to finally fix this issue!! 1)Download and Install Xina 1.1.8 from TrollStore and Filza Trollstore edition and hit Jailbreak it will proccess it and it will work with Dopamine 2)You dont need Xina, Reboot, Go to Xina settings hit safe mode hit jailbreak 3)Now you can delete everything from /var/jb/Application!!!! in Filza but don't do it since there will be nothing because you are on Xina so 4)Go to /private/preboot/(YOUR SPECIAL ID)/jb-(some letters)/procursus/Application and delete every file inside there If you need TrollStore version of Sileo until Opa fixes it, I can give it to you and Zebra too

you really want to get blocked, do you? your bs has NOTHING to do with this issue so keep it out of it please

I mean if this fix works for many people, than I might be just right, why don't you consider that?

dollarystem commented 1 year ago

Right now Im flawless Dopamine user with Trollstored all apps because of this issue and its fine

Cryptiiiic commented 1 year ago

the real question is when did we even ask, we didn't

bgli100 commented 1 year ago

no successful checkins from backboardd since load service: backboardd, no successful checkins since load (180 seconds ago) service: mediaserverd, no successful checkins since load (180 seconds ago) service: logd, total successful checkins since load (180 seconds ago): 19, last successful checkin: 0 seconds ago service: thermalmonitord, no successful checkins since load (180 seconds ago) service: runningboardd, no successful checkins since load (180 seconds ago) service: wifid, total successful checkins since load (180 seconds ago): 13, last successful checkin: 0 seconds ago

This panic was prevented by Dopamine and jailbreakd triggered a userspace reboot instead.

bgli100 commented 1 year ago

Tried to add com.apple.UIKit back in 1.1 and it seems Dopamine collects more info on failure now. Not sure if it helps or gives hint on what I am breaking. (Or, how to avoid injecting those deamons?)

bgli100 commented 1 year ago

Figured out the issue.

  1. A silly mistake, I used theos' default SDK (for 14.5) for compiling tweak which is intended for 15.0+.
  2. Tweak should have BOTH arm64 and arm64e for ARCH. It is not gonna work if you only have one.

By viewing crash log of Mail/News app, it seems dyld refuse to work with such dylibs and choose to crash (not sure if it is the same issue for userspace reboot).