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

PPSSPP crashes on iOS in 64-bit builds with JIT (32-bit works) #9232

Closed
iOS4all opened this issue Jan 24, 2017 · 37 comments
Closed

PPSSPP crashes on iOS in 64-bit builds with JIT (32-bit works) #9232

iOS4all opened this issue Jan 24, 2017 · 37 comments

Comments

@iOS4all
Copy link

iOS4all commented Jan 24, 2017

@hrydgard hi there. As I mentioned above in the title. All later versions of ppsspp on iOS are crash when we select roms. and the last version which is working was 1.3-191 so please if you can see what's causing this crash we'll be thankful. Specially on the latest version of ppsspp you merge the important feature which is called (Hardware Tessellation). So if you can investigate about the issue of causing the crash.
Thanks a lot.

@hrydgard
Copy link
Owner

I'm going to look into it tomorrow.

@iOS4all
Copy link
Author

iOS4all commented Jan 24, 2017

Ok thank you very much. Really appreciate a lot.

@hrydgard
Copy link
Owner

Just managed to get it all building with XCode and running on my iPad, and I got it to crash with the debugger connected. Ready to debug tomorrow!

@iOS4all
Copy link
Author

iOS4all commented Jan 24, 2017

@hrydgard thank you so much for taking care to fix the crash.
Looking forward to it.

@hrydgard
Copy link
Owner

hrydgard commented Jan 25, 2017

Alright, here we go. There might be two problems here.

First, we now build PPSSPP for both ARM32 and ARM64 on iOS, and our memory allocation mmap tricks (for "fastmem") do not work on 64-bit iOS. However, there may be a way out, the mach memory allocation APIs vm_allocate and friends. I'm looking into that now. If that doesn't pan out we'll have to do an uglier solution that will have to sacrifice some performance.

Second, the mentioned culprit commit would seem to indicate that there's another crash that affects 32-bit or possible both 32-bit and 64-bit iOS. I can't debug that until I solve the first crash though, and this might actually not be a real crash, not sure yet.

@tausifj15
Copy link

Yeah sir new builts have performance issues in some games

@hrydgard
Copy link
Owner

Alright, vm_allocate+vm_remap can indeed do address space mirroring.

But now I ran into a nasty issue. It turns out that iOS only uses 33 bits of each pointer, and also bans the lower 4GB from usage, meaning that the entire addressable address space is from 0x100000000 to 0x1FFFFFFFF. In there, I am unsuccessful in allocating a 0xE1000000 block of contiguous address space, which I need for the straightforward version of fastmem trick.

Since we only really need a few rather small "islands" of that space, there's still hope, but I'm going to have to implement a probing solution to find a memory base pointer that can reach the offsets we need, similar to what we do on 32-bit Windows. Gah :(

@tausifj15
Copy link

Sir im on android

@hrydgard
Copy link
Owner

In this thread, I am talking about my iOS efforts. One thing at a time.

@iOS4all
Copy link
Author

iOS4all commented Jan 25, 2017

@hrydgard We really appreciated whatever you did to fix these issues.
As I mentioned above the last working version was 1.3-191. Also if you want to give you that working version it's my pleasure. Because I still have it.

Also I noticed the new JIT recompiler had some micro stutter. Maybe if you fix the issue of fastmem on 64-bit it gonna work again like the old JIT. Which is bug free and no stutter at all.
Anyway do whatever you see it good. And take your time.
Thanks....

@hrydgard
Copy link
Owner

Working on it, I think I have a promising approach now.. I will solve it :)

Also I have a new suspicion about the cause of the stutter and this might just fix it...

@iOS4all
Copy link
Author

iOS4all commented Jan 25, 2017

@hrydgard WOW all I can say WOW that's really great news I have ever heard.
You can't imagine how bad of that stutter which is happened every 3-4 seconds that's really annoying a lot.
If you fix that we will be very thankful forever. Thank you for you hard work. Really appreciated...

@hrydgard
Copy link
Owner

hrydgard commented Jan 25, 2017

Don't want to promise too much, no guarantees for no stutter yet.. There's something strange and crashy going on still though..

@hrydgard
Copy link
Owner

hrydgard commented Jan 25, 2017

OK so I've managed to get things running on iOS ARM64 if you turn off the CPU JIT. Though the vertex JIT is working, so the last bug should be fixable ... might have to wait until tomorrow though. I'll merge the above when the CI buildbot passes.

@iOS4all
Copy link
Author

iOS4all commented Jan 25, 2017

@hrydgard ok We'll waiting for these fixes patiently. Hopefully it's gonna fix the micro stutter as well.
If the new bulid come to cydia I'll test it and give you my report if you want.
I have jailbroken iPhone 7 plus on 10.1.1 as well as ipad air 2 on 9.3.3.

(Just for knowing)

before I updated my iPad Air 2 to 9 it was on iOS 8.4 with TaiG jailbreak and ppsspp running without any issues or even micro stutter at all. All games run at 30/60fps without any drop in the speed at all
I know TaiG always patch the kernel. and the kernel including JIT. Unlike Pangu always come with broken kernel. I know all that because of KPP (Kernel Patch Protection) apple made it for 64 bit devices. Even the last jailbreak from Pangu it just avoid KPP not bypass it. So that's why the JIT not come like on iOS 8.

So the latest jailbreak which is for iOS 10.1.1 the creator (Loca) said he could bypass KPP successfully.
But I wonder how to could implement an old JIT on it.

Anyway I give you this information to be familiar on something maybe it missed from someone of you. Excluding @hrydgard because he has a deep knowledge on these stuffs.

Thanks.

@hrydgard
Copy link
Owner

New build with these changes should be coming to cydia when the buildbot feels like making it, it's a little unpredictable :)

Again the main CPU JIT doesn't work yet so you'll have to go into tools/developer settings and change CPU core to IR Interpreter or Interpreter.

@Sophie94
Copy link

I thank mr.henrik for his hard work
@iOS4all
Can you please give me ppsspp that really still working on your iPad device! As dep file?

@iOS4all
Copy link
Author

iOS4all commented Jan 25, 2017

Thanks again for your hard work. Are you going to bring JIT back after fixing its issue?

@hrydgard
Copy link
Owner

Well the bug is the only thing stopping it, so yeah, of course :)

Can't promise I'll find the bug soon though, but I'll try.

@iOS4all
Copy link
Author

iOS4all commented Jan 25, 2017

@Sophie94 of course here you go.
https://www.dropbox.com/s/hiq6dkaxonhrmrd/org.ppsspp.ppsspp-dev-working_0v1.3-191-gaa964ea_iphoneos-arm.deb?dl=0

@hrydgard we all counting on you to fix it. So take your time.

@iOSSOi
Copy link

iOSSOi commented Jan 29, 2017

Anything new on the iOS micro stutter?

@iOS4all
Copy link
Author

iOS4all commented Jan 29, 2017

@iOSSOi don't worry @hrydgard is work on solving this annoying issue. And we'll waiting to finish his fix

@kpwn
Copy link

kpwn commented Feb 4, 2017

But now I ran into a nasty issue. It turns out that iOS only uses 33 bits of each pointer, and also bans the lower 4GB from usage, meaning that the entire addressable address space is from 0x100000000 to 0x1FFFFFFFF. In there, I am unsuccessful in allocating a 0xE1000000 block of contiguous address space, which I need for the straightforward version of fastmem trick.

this is not entirely true: the real range is from 0x10000 to 0x1ffffffff: you just need to change the __PAGEZERO segment size to be lower than the default 4GB. This should suffice to solve the fastmem issue.

@hrydgard
Copy link
Owner

hrydgard commented Feb 4, 2017

@kpwn Hm, interesting. Some linker magic to do that, I suppose?

@kpwn
Copy link

kpwn commented Feb 5, 2017

Yes: -Wl,-pagezero_size,0x10000 will do it for you.

@kpwn
Copy link

kpwn commented Feb 5, 2017

I actually think I am tripping and the smallest value can actually be 0x4000, but I may be tripping in my thinking I am tripping. I am not looking at code and not able to try right now. Am certain 10000 works however.

@hrydgard
Copy link
Owner

hrydgard commented Feb 5, 2017

Well, 0x4000 or 0x10000 shouldn't really matter for our purposes. Thanks for the tip, I'll try it when I next look at iOS again.

@hrydgard hrydgard changed the title All later versions of ppsspp on iOS beyond (v1.3-191) are crash. Need help please. PPSSPP crashes on iOS in 64-bit builds with JIT (32-bit works) Feb 6, 2017
@hrydgard hrydgard added this to the v1.4.0 milestone Feb 6, 2017
@iOS4all
Copy link
Author

iOS4all commented Feb 15, 2017

@hrydgard thanks for taking care of that.
We'll waiting patiently.

@iOS4all
Copy link
Author

iOS4all commented Feb 19, 2017

@hrydgard nice to see you always trying to helping people here.
Also I would to thank you for taking care of these issues related to iOS to the next major update (v1.4.0).
We'll waiting for this update patiently only for fix micro stutter. This is our hope as an iOS users. I feel jealous of other platforms not having this annoying issue.
Anyway take your time and keep going man.

@hrydgard
Copy link
Owner

Note to self for the next time I'm looking at iOS: I just figured at least one reason this isn't working. Our ARM64 backend currently assumes that the PSP memory space is aligned to 4GB. This is so that it can turn PSP pointers into emulator pointers by using the movk ARM64 instruction to poke the base of the PSP memory space into bits 32-48 of the pointer.

When, like on iOS, we use an unaligned memory space, this will not work at all.

@CodeEagle
Copy link

CodeEagle commented Jun 4, 2017

still waiting for fixing

@iOSSOi
Copy link

iOSSOi commented Jun 4, 2017

Any chance till will be solved for the next official release?

@iOS4all
Copy link
Author

iOS4all commented Jun 16, 2017

There's a semi-fix for this stutter. is while you play psp games just keep ppsspp running in background and go to cydia and download a big size app like (retoarch) then while you download it go back to ppsspp and you'll notice there's no stutter at all. You can enjoy until finished retroarch from downloading after that you'll notice the stutter is returning back again. If take this method maybe it'll open the door for permanent fix.

@SpiralCut
Copy link

I can get JIT to work if I set Xcode to only compile for Armv7. However, it hangs the system on exit on my iPhone 6s, is that expected?

@unknownbrackets
Copy link
Collaborator

@hrydgard I suppose we shouldn't pointerize at all on iOS 64 - adding fallback paths around MapRegAsPointer, and error if address is not 48-bit and 4GB aligned. Looks problematic to try "temporary pointerization" with undo at the end of the instruction or anything, in cases of multiple reads or stores.

We could add that somewhere in js or jo at startup, and set cachePointers to false.

@atsumori666 not expected, but I think that's already been reported. PPSSPP could use someone to more actively maintain the iOS code. It's a small wrapper, but would benefit from someone interested in learning / already knowledgeable in iOS programming contributing.

-[Unknown]

@Vertpin
Copy link

Vertpin commented Jul 21, 2017

Trying to play Persona 3: Portable on my iPhone 7. Using IR Interpreter. Does not run as smooth as it should at all, and over time starts to chug a lot.

Any ETA when JIT will be back as an option that doesn't crash?

@unknownbrackets
Copy link
Collaborator

At least some 64-bit builds work now (see #10465, #10467.)

It will be surprising if iOS 11 even works (which is #9833, not this bug), and various jailbreak hacks seem to have bugs that also cause PPSSPP to crash. But as far as 64-bit issues (this bug), it should be fixed.

-[Unknown]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants