love icon indicating copy to clipboard operation
love copied to clipboard

fullscreen config in `conf.lua` prevents setting initial orientation on iOS 16

Open ParticleG opened this issue 2 years ago • 12 comments

It seems this issue love-android #196 happens on iOS16 again. If you use the following configs:

t.window.width,t.window.height=1280,720
t.window.fullscreen=true
t.window.resizeable=false

Then launch the game with your phone standing portrait, the game would be in portrait mode even the window.width is greater than window.height.

This didn't happen on iOS 15. See discussions in our game's issue: Techmino #847

Example project code on Techmino/ci-ios-test, result on 15 and 16:

image

ParticleG avatar Feb 21 '23 09:02 ParticleG

Here's the commit for that Android fix: 9c4db00e9490742317d4a493f5c11d7f7e200124

If you could change the relevant codepath to also run on iOS, by changing the #if by adding LOVE_IOS define check too, does it solves the issue?

MikuAuahDark avatar Feb 21 '23 09:02 MikuAuahDark

Would test with git patch and love-actions-ios CI, since I have no mac dev env for now

ParticleG avatar Feb 21 '23 10:02 ParticleG

I doubt that Android-specific change would affect much at all on iOS. The two platforms have radically different codepaths in SDL (which is meant to handle this stuff) - historically SDL's Android backend has sort of been its own thing, whereas the iOS backend behaves similarly to other platforms.

As a workaround, setting the available orientations via the Xcode project will probably work in the meantime. See platform/xcode/love-ios.plist if you want to edit the file that has that information (UISupportedInterfaceOrientations etc).

slime73 avatar Feb 21 '23 12:02 slime73

I doubt that Android-specific change would affect much at all on iOS. The two platforms have radically different codepaths in SDL (which is meant to handle this stuff) - historically SDL's Android backend has sort of been its own thing, whereas the iOS backend behaves similarly to other platforms.

As a workaround, setting the available orientations via the Xcode project will probably work in the meantime. See platform/xcode/love-ios.plist if you want to edit the file that has that information (UISupportedInterfaceOrientations etc).

I've tried, but our game need to change orientation with in game settings

ParticleG avatar Feb 21 '23 15:02 ParticleG

Actually it behaves weird, as if the game read the wrong width and length data, the game scene is cropped.

Launch portrait: F9F4FC9D-CC08-414F-A053-8FEC36EE1C1C

Launch landscape: 3E94B503-36EC-4211-A56E-32F24C509C74

Sorry but I can’t provide any debugging information, since my Mac is too old and keeps running out of memory. Test branch: ci-ios-fix Git patch: love.patch

ParticleG avatar Feb 21 '23 15:02 ParticleG

This isn't something love's own source code can likely fix either way. There was a workaround recently for something similar inside SDL's source code (https://github.com/libsdl-org/SDL/issues/6289) but I don't think the workaround will necessarily fix this issue - you could try using the latest SDL2 release even so.

slime73 avatar Feb 21 '23 15:02 slime73

is there any build script let me can build SDL2.xcframework library?? https://github.com/love2d/love-apple-dependencies/tree/main/iOS/libraries/SDL2.xcframework

I'm new to iOS develop, I think may it has a script like: https://github.com/love2d/love/blob/9963d1247c05b303caf7c61e8016315a1cd33465/platform/xcode/ios/luajit-iOS.sh#L10

bytemain avatar Feb 22 '23 07:02 bytemain

is there any build script let me can build SDL2.xcframework library?

The Xcode project in the latest SDL2 versions has an xcframework iOS target I believe. I haven't tested it myself yet but hopefully it'll work without needing to change anything. Otherwise you can build a static library and use the xcodebuild -create-xcframework command to generate one from one or more static libraries.

slime73 avatar Feb 22 '23 12:02 slime73

the xcframework target in SDL2 framework's structure like this: CleanShot 2023-02-22 at 21 34 06@2x

but the xcframework of love2d is: CleanShot 2023-02-22 at 21 35 55@2x

this will cause an error: CleanShot 2023-02-22 at 21 38 35@2x

bytemain avatar Feb 22 '23 13:02 bytemain

Thanks for your second advice, I will try it later.

bytemain avatar Feb 22 '23 13:02 bytemain

looks like SDL2 2.26.3(latest) still have this problem.


you can use follow steps to create a new SDL2.xcframework

Firstly, build static library for iOS:

CleanShot 2023-03-03 at 19 53 33@2x

then open the build folder and copy that path: CleanShot 2023-03-03 at 19 54 08@2x

xcodebuild -create-xcframework -library {BUILD_PATH}/Products/Release-iphoneos/libSDL2.a -headers {SOURCE_DIR}/include -library  {BUILD_PATH}/Products/Release-iphonesimulator/libSDL2.a -headers {SOURCE_DIR}/include -output SDL2.xcframework

replace the {SOURCE_DIR} to source code path, replace the {BUILD_PATH} to the xcode build folder.

bytemain avatar Mar 03 '23 11:03 bytemain

I've done some debugging and I have a potential fix for the issue in SDL, but I need to test it more.

However, setting fullscreen without setting exclusive fullscreen will use fullscreen-desktop mode. Fullscreen-desktop always uses the native screen resolution instead of changing it based on the requested dimensions. On iOS that means even if you request landscape or whatever via setting width and height it won't use it, and will likely default to portrait mode.

The bug still exists when you request exclusive fullscreen with landscape though, and that's what I'm fixing.

slime73 avatar Jul 23 '23 16:07 slime73