question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Investigate feasibility of iOS support (prototype attached)

See original GitHub issue

Feature Request

What feature are you suggesting?

Overview:

Ryujinx recently added support for macOS Apple Silicon / Metal. This support can be used as the foundation for an iOS port.

I made a terrible prototype Ryujinx launcher that launches an unmodified Ryujinx 1.1.0-macos1 build on an iPhone 14 Pro on iOS 16.1. It barely runs a homebrew game, but it proves that iOS support may be possible.

I do not expect iOS devices to be able to run games at full speed and fidelity in the short term. However, they may be able to emulate small/simple games.

I’m not sure how feasible or worthwhile an iOS port would be, so I’m creating this feature request to list the limitations / challenges I encountered when building the prototype.

Please let me know whether this is worth pursuing, and what I should do to help.

Smaller Details:

For my prototype, I used:

  • Modified .Net Core CoreCLR v7.0.1.
    • I chose this instead of e.g. MonoAOT since Ryujinx is only tested on CoreCLR and I don’t want to debug MonoAOT incompatibilitiess
    • As a hack, CoreCLR is built using the macOS target (i.e OperatingSystem.IsMacOS is true and IsIOS is false), but using the iOS SDK, to minimize the changes required
  • Unmodified SDL2
  • Slightly modified MoltenVK
  • Ryujinx’s 1.1.0-macos1 binary release, extracted using sfextract and patched to backport the x18 fix from the pull request
  • Ryujinx.Headless.SDL2 built from source, with some changes to match the binary build.
  • A launcher that loads CoreCLR and starts Ryujinx.Headless.SDL2

This was enough to run Helltaker, a homebrew 2D Unity game by D3fau4 / vanripper - with occasional crashes from running out of memory or the GPU not responding (probably also out of memory?).

I did not try running any commercial games, because it barely ran a 2D homebrew as is - I doubt it’d would be able to handle anything more.

The main issues preventing Ryujinx from emulating a Switch on iPhone are:

  • lack of physical memory: The Switch has 4GB of RAM, and Ryujinx itself requires at least an additional 1.5GB of RAM. The iPhone 14 Pro only has 6GB RAM total. According to jduncanator, there is also significant extra RAM usage from Ryujinx emulating VRAM and decompressing/recompressing textures.

  • lack of virtual memory: A desktop computer gives each application hundreds of terabytes of virtual memory. ~iOS gives each app less than 8GB by default (!!)~ ~This is barely enough to fit Ryujinx’s various reserved memory regions, such as the emulated 4GB Switch memory or the 512MB JIT cache.~ ~Even with a $100/year developer membership, you can only get 64GB of virtual memory.~ Update (2023-01-22): I was wrong: free apps can ask for 64GB of address space using the extended memory entitlement. This is still well below the amount you get on desktop platforms.

    I had to patch Helltaker’s .nca npdm flags to choose a 36-bit instead of a 39-bit address space, because there’s not enough host virtual address space to allocate the 1GB JIT pagetable Similarly, I intercept the mmap for 2GB of JIT cache and return only 512MB, since there’s no space for 2GB.

    JIT Host memory will probably never work, as discussed on Twitter: even with a paid account you get only 64GB of host address space, or 36 bits, so host emulation would leave no memory for Ryujinx itself.

  • lack of hypervisor support: Ryujinx on macOS uses Hypervisor.framework to run Switch’s CPU code directly iOS does not offer this framework, so Ryujinx has to fall back on the slower JIT.

  • missing Metal features Even in Helltaker, a simple Unity-based homebrew, Ryujinx on iOS fails to render the selected highlight around its menu options. Ryujinx on macOS Apple Silicon does render it correctly, so it appears iOS Metal / MoltenVK is missing features.

  • Apple’s stance on JIT and emulation Emulators are not allowed on the App Store, so emulators must be sideloaded. This is much more involved than downloading apps from the store: the user must set up some way to sideload the app, for example, using AltStore, and the app must be re-installed every 7 days. While sideloaded apps can access JIT (unlike app store apps), the procedure is a hassle to set up.

Nature of Request:

  • Addition
    • Investigate whether Ryujinx can be sideloaded to iOS devices with >=6GB of RAM, and what its limitations would be

Why would this feature be useful?

For users, it would offer an additional option to emulate games on the go.

  • Android devices already have a popular Switch emulator (Skyline). This shows that there are users who want to emulate the Switch on mobile devices.
  • While emulators are not allowed on the iOS App Store, iOS users already have access to several emulators through sideloading, such as Delta and Dolphin-iOS. This shows that iOS users are interested in emulation.

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:18
  • Comments:39 (12 by maintainers)

github_iconTop GitHub Comments

12reactions
ansinerdcommented, Jan 2, 2023

Well I am no dev by any means, nor I can contribute by any means other than may be patreon support. I just wanna make few points that I believe represent the wish/opinion of thousands of iOS users. First of all we thank zhuowei, jd, and gdkchan for your time to even discuss the possibility of an ios port. we are much thankful for your other works as well.

  1. iPad pros with apple silicon comes with 8/16gb of physical RAM and apparently 64+ VRAM support. May be a port for apple silicon only devices can be made? M1/M2 iPads got insane power for a mobile device.
  2. iOS users are very much used to of sideloading and debugging JIT etc. Altstore/sidestore made on device sideloading a very easy method to sideload emus, the ios emu community has grown multifold with arrival of dolphin and even flycast, also ps2 emu like play! is also making steady progress in right direction. So sideloading would not be an issue at all.
  3. iOS users want emulators. With arrival of backbone one like telescoping controllers, iPhones have become portable gaming device for thousands of us and it keeps on growing only. PPSSPP, DOLPHIN, FLYCAST or RA have become playable at full speed and make emulation easier on phone for those of us who don’t have pcs.
  4. Per believing the rumour and leaks, apple is considering allowing third party app stores, sideloading and even opening their browser engines as well with iOS 17, most of us believe (including many devs as well) that in coming months ios emulation will improve greatly.

In the end all I wanna request with lots of gratitude is that, please don’t close this request, even if its low priority, keep it open, who knows within few months ios becomes more emulation friendly with upcoming os update. We as a community will forever be grateful to you and those who are contributing to community of gamers. Thank you so much.

3reactions
jduncanatorcommented, Jan 2, 2023

Thanks for all your work on this, I’ve been eagerly following your work on Twitter the last couple of days.

I think until we see an iPhone with 8GB of RAM released, that the market for this is going to be pretty slim. Skyline works (and can potentially be an actually useable emulator) because Android devices exist with 8GB and 12GB of memory.

With that said, there is a lot of potential for optimising memory usage on UMA architectures, and with the better memory API’s available on macOS/iOS a lot of the VA used for address space mirrors (etc) could be optimised.

The 64GB of VA is always going to be a killer though. If anything, Ryujinx is likely moving in the direction of requiring more VA rather than less, with things like multi-process (and applet support) something that will likely come on the radar in 2023. Both of those things require maintaining a separate 36+ bit VA for each process/applet. You might be able to cobble together a build for iOS that didn’t support those features, but the question is then about how many compromises you’d need to make before it’s not worth it anymore, rather than is it possible at all.

I know there is an entitlement for a larger address space on iPad Pro’s, is that the same thing as the paid expanded 64GB VA on iPhone, or is that expanded address space even larger on iPad? Perhaps a more realistic target is Ryujinx on iPad…

All in all, thanks massively for your work. Especially the launcher code, and the detailed documentation you’ve made, this will make it much easier for anyone to dabble with Ryujinx on iOS in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Zhuowei Zhang
Feature Request : Investigate feasibility of iOS support (prototype attached) · Issue #4198 ·... Feature Request What feature are you suggesting?
Read more >
How do you file a feature request? | Apple Developer Forums
How do you file a feature request? ... If you go to https://feedbackassistant.apple.com and create a new feedback (for iOS and iPad) item,...
Read more >
How to Create a Mobile App Prototype (2023)
Learn how to engage with prototype design and understand how prototyping tools help you develop better prototype testing and refinements.
Read more >
Prototype Testing: A Step by Step Guide (2023) | Blog
Learn how to validate your designs and test your prototype. ... Prototypes offer the basic functionality of product discovery.
Read more >
The feasibility of using Apple's ResearchKit for recruitment ...
We argue that smartphone-based trials (using ResearchKit) require a well-designed app dissemination process to attain a sufficient sample size.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found