From 6f3ca6c22a7f373e75387306db7329d1ff2ab25a Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 7 Jul 2023 01:36:49 +0300 Subject: [PATCH 1/5] Disable Mono interpreter on release mode --- osu.Framework.iOS.props | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/osu.Framework.iOS.props b/osu.Framework.iOS.props index 4effbe4d72..47a1552dca 100644 --- a/osu.Framework.iOS.props +++ b/osu.Framework.iOS.props @@ -1,15 +1,20 @@  iPhone Developer - - true true $(NoWarn);MT7091 + + + true + + + + false + ios-arm64 From 06b8cd3ebe5c91046a9018792cd18dc26b65a2fb Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 7 Jul 2023 01:40:56 +0300 Subject: [PATCH 2/5] Fix SDL library not found exception with AOT enabled Depends on https://github.com/ppy/SDL2-CS/pull/169 --- osu.Framework.iOS/GameApplication.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Framework.iOS/GameApplication.cs b/osu.Framework.iOS/GameApplication.cs index c0b8ff0b3f..9e95e0804f 100644 --- a/osu.Framework.iOS/GameApplication.cs +++ b/osu.Framework.iOS/GameApplication.cs @@ -32,6 +32,7 @@ public static void Main(Game target) game = target; + SDL.PrepareLibraryForIOS(); SDL.SDL_UIKitRunApp(0, IntPtr.Zero, main); } From 3df1db116bc9a702b1f5bc14947728d274d65075 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 7 Jul 2023 03:07:00 +0300 Subject: [PATCH 3/5] Fix iOS main run loop method requiring JIT compilation --- osu.Framework.iOS/IOSWindow.cs | 12 +++++++++++- osu.Framework/Platform/SDL2Window.cs | 11 +++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/osu.Framework.iOS/IOSWindow.cs b/osu.Framework.iOS/IOSWindow.cs index ad4f5d389f..1e0e404ff3 100644 --- a/osu.Framework.iOS/IOSWindow.cs +++ b/osu.Framework.iOS/IOSWindow.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Drawing; using ObjCRuntime; +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Platform; using SDL2; @@ -60,7 +61,16 @@ protected override void RunMainLoop() // frame rate with multi-threaded mode turned on, but it is going to give them worse input latency // and higher power usage. SDL.SDL_iPhoneSetEventPump(SDL.SDL_bool.SDL_FALSE); - SDL.SDL_iPhoneSetAnimationCallback(SDLWindowHandle, 1, _ => RunFrame(), IntPtr.Zero); + SDL.SDL_iPhoneSetAnimationCallback(SDLWindowHandle, 1, runFrame, ObjectHandle.Handle); + } + + [ObjCRuntime.MonoPInvokeCallback(typeof(SDL.SDL_iPhoneAnimationCallback))] + private static void runFrame(IntPtr userdata) + { + var handle = new ObjectHandle(userdata); + + if (handle.GetTarget(out IOSWindow window)) + window.RunFrame(); } private void updateSafeArea() diff --git a/osu.Framework/Platform/SDL2Window.cs b/osu.Framework/Platform/SDL2Window.cs index 553745cda3..ee987ac999 100644 --- a/osu.Framework/Platform/SDL2Window.cs +++ b/osu.Framework/Platform/SDL2Window.cs @@ -174,11 +174,14 @@ internal SDL.SDL_SysWMinfo GetWindowSystemInformation() [UsedImplicitly] private SDL.SDL_EventFilter? eventFilterDelegate; - private ObjectHandle objectHandle; + /// + /// Represents a handle to this instance, used for unmanaged callbacks. + /// + protected ObjectHandle ObjectHandle { get; private set; } protected SDL2Window(GraphicsSurfaceType surfaceType) { - objectHandle = new ObjectHandle(this, GCHandleType.Normal); + ObjectHandle = new ObjectHandle(this, GCHandleType.Normal); if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_GAMECONTROLLER) < 0) { @@ -250,7 +253,7 @@ public virtual void Create() /// public void Run() { - SDL.SDL_SetEventFilter(eventFilterDelegate = eventFilter, objectHandle.Handle); + SDL.SDL_SetEventFilter(eventFilterDelegate = eventFilter, ObjectHandle.Handle); RunMainLoop(); } @@ -614,7 +617,7 @@ public void Dispose() Close(); SDL.SDL_Quit(); - objectHandle.Dispose(); + ObjectHandle.Dispose(); } } } From 507375ed0dee916c8733297ad8776db86cef3af9 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Fri, 7 Jul 2023 03:49:18 +0300 Subject: [PATCH 4/5] Update packages --- osu.Framework/osu.Framework.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Framework/osu.Framework.csproj b/osu.Framework/osu.Framework.csproj index af1fe63ae4..3f6375c101 100644 --- a/osu.Framework/osu.Framework.csproj +++ b/osu.Framework/osu.Framework.csproj @@ -27,7 +27,7 @@ - + @@ -38,7 +38,7 @@ - + + true - + false