Play- icon indicating copy to clipboard operation
Play- copied to clipboard

iOS - Libretro - Insta-Crash when loading up disc iso

Open mrjschulte opened this issue 4 years ago • 15 comments

I am able to build Play! for use with Libretro Retroarch on iOS as follows: git clone -j24 https://github.com/libretro/libretro-super.git cd libretro-super git clone -j24 --recursive https://github.com/jpd002/Play-.git mv Play- libretro-play CMAKE=cmake VERBOSE=1 SINGLE_CORE=play FORCE=YES EXIT_ON_ERROR=1 ./libretro-buildbot-recipe.sh recipes/apple/cores-ios-arm64-generic cp play_libretro_ios.dylib /retroarch/pkg/apple/iOS/modules/

The above steps produce a valid ios-arm64 Libretro core that can be installed and code signed by Xcode when compiling Retroarch for iOS.

When attempting to load a ps2.iso, which works fine on the standalone macOS Play! version, we get an immediate crash as follows: Thread 1: EXC_BAD_ACCESS (code=1, address=0xe8) on line 237 in where it states: apple->joypad,

if (binds[port][id].valid) { if (button_is_pressed( apple->joypad, joypad_info, binds[port], port, id)) return 1;

Any ideas on what could be causing this issue?

mrjschulte avatar Aug 23 '20 18:08 mrjschulte

Doing some more debugging we see it dumps out the following message when attempting to load the .iso: PS2VM: Error mounting cdrom0 device: Invalid file handle.

mrjschulte avatar Aug 23 '20 18:08 mrjschulte

Hi there! What is the path provided to the emulator core? You can inspect the path here: https://github.com/jpd002/Play-/blob/038d564cafb24d94edfa7756fccdb1216aed780d/Source/PS2VM.cpp#L705.

jpd002 avatar Aug 23 '20 21:08 jpd002

Hi there, Looking at the generated config file for Play! that is in the root folder for the iOS install location on the iPad, I see the following path: <Preference Name="ps2.cdrom0.path.v1" Type="path" Value= /private/var/mobile/Containers/Data/Application/43D86-0FF8-4422-A3C8/Documents/RetroArch/downloads/ps2/psgen.iso"/>

Was there another means you would like me to use?

mrjschulte avatar Aug 23 '20 22:08 mrjschulte

Hmmm, looking at the results of my compilation, it resets the play git pull back to head blowing away my changes to get the print statement for the printf("PS2VM: mounting cdrom0 device: %s\r\n", m_cdrom0.get()); I added in for line 706. Any way around that?

mrjschulte avatar Aug 23 '20 22:08 mrjschulte

Any hints on what the print statement would be to get the location of the path that it is trying to use @jpd002 ? I tried adding in printf("PS2VM: mounting cdrom0 device: %s\r\n", SetIopOpticalMedia); but no go.

mrjschulte avatar Aug 27 '20 03:08 mrjschulte

Something like printf("PS2VM: mounting cdrom0 device: %s\r\n", path.string().c_str()); should do the trick.

jpd002 avatar Aug 27 '20 12:08 jpd002

Path is valid and seems too check out:

PS2VM: Error mounting cdrom0 device: Invalid file handle. PS2VM: mounting cdrom0 device: /private/var/mobile/Containers/Data/Application/9C3B6327-2C1C-4C2C-8A5C-6D99C912B246/Documents/RetroArch/downloads/ps2/psgen2.iso

mrjschulte avatar Aug 29 '20 16:08 mrjschulte

Is there a next step that you would like me to try to help track this issue down?

mrjschulte avatar Sep 07 '20 16:09 mrjschulte

You're aware that JIT (all self executable code in all emulators) doesn't work in iOS updates anymore right?

There are a bunch of emulator authors like in beetle and ppsspp saying in bug report pages 'sorry can't do anything about apple'... rightfully. People have warning other people about apple for years.

Anyway i was thinking it might be another (JIT related) error being hidden by a higher level failure after that error occurs. I'm not even sure if this emulator core uses JIT though, since there no related option to turn it off so...

i30817 avatar Sep 08 '20 00:09 i30817

@i30817 AFAIK JIT works under certain conditions on iOS. It's working for me on iOS 13.6.1 at least (haven't tried iOS 14).

@mrjschulte Path looks fine, I dunno why the emulator would have problems opening that file, it only does a fopen in the end. Still, can you try something like that to see what happens?

printf("PS2VM: opening file for cdrom0 device: %p\r\n", fopen(path.string().c_str(), "rb"));

Could you also provide the call stack of the crashed thread for the crash that you mentioned in your first post?

Thanks!

jpd002 avatar Sep 08 '20 13:09 jpd002

@i30817 AFAIK JIT works under certain conditions on iOS. It's working for me on iOS 13.6.1 at least (haven't tried iOS 14).

https://saagarjha.com/blog/2020/02/23/jailed-just-in-time-compilation-on-ios/

The workaround no longer works in (unhacked i presume) iOS 14.

Though i suppose i should not insist that this bug is about this, at least until the OP says he's using iOS 14.

i30817 avatar Sep 08 '20 13:09 i30817

Thanks for that piece of info @i30817! And boo Apple!

jpd002 avatar Sep 08 '20 14:09 jpd002

I got a similar crash on Windows. I think it's unrelated to OS.

jpd002 avatar Nov 09 '20 15:11 jpd002

For what it's worth, I've seen no crash issues on x86_64 Linux whatsoever. Various other issues, sure, but most of those are presumably in the compatibility realm. While it may not be exclusive to iOS, I wouldn't say it's unrelated.

Sanaki avatar Nov 09 '20 15:11 Sanaki

Here's what was my experience: I was testing a single game using the same core I built locally. Using a RetroArch built locally, I had no problems, but the one I installed from the official website is crashing.

My hunch is that it has something to do with a controller being plugged in, but I didn't have time to test this.

jpd002 avatar Nov 09 '20 17:11 jpd002