Ppsspp: PPSSPP crashes on iOS in 64-bit builds with JIT (32-bit works)

Created on 24 Jan 2017  路  37Comments  路  Source: hrydgard/ppsspp

@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.

Platform-specific (iOS)

Most helpful comment

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.

All 37 comments

I'm going to look into it tomorrow.

Ok thank you very much. Really appreciate a lot.

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!

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

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.

Yeah sir new builts have performance issues in some games

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 :(

Sir im on android

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

@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....

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...

@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...

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

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.

@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.

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.

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?

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

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.

@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.

Anything new on the iOS micro stutter?

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

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.

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

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

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.

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 thanks for taking care of that.
We'll waiting patiently.

@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.

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.

still waiting for fixing

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

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.

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?

@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]

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?

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]

Was this page helpful?
0 / 5 - 0 ratings