love2d / love-android

Android build setup for LÖVE.
https://love2d.org
Other
202 stars 70 forks source link

Build crashes if fullscreen & getSafeArea() is called. #277

Open HugoAdams opened 1 month ago

HugoAdams commented 1 month ago

If fullscreen is set to true, either through love.conf(), love.window.setFullscreen() or love.setMode() and then love.window.getSafeArea() is called then the application will crash.

function love.load()
    love.window.setFullscreen(true)
    print(love.window.getSafeArea())
end

If you run this code, logcat will show multiple errors.

The application will run fine if setFullscreen is called without calling getSafeArea and vice versa. It just means you cannot access the safe area while in fullscreen mode.

However, getSafeArea() can be called before setting fullscreen, but this does not work as the safe area returned has x and y set to 0, 0. If these were accurate numbers this method might be usable.

MikuAuahDark commented 1 month ago

May I know the LOVE version you're using on?

HugoAdams commented 1 month ago

This was on 11.4, but it seems to effect 11.5 too.

slime73 commented 1 month ago

If you run this code, logcat will show multiple errors.

What are the errors (when running with 11.5)?

HugoAdams commented 1 month ago

This is a logcat of the crash (github doesn't let me upload it directly). This is tested on a physical device (Samsung Galaxy Z Flip 3), the code I posted earlier seems to work ok on some virtual devices in Android Studio.

I think this is because devices in Android Studio do not simulate the safe area unless you use the developer option to Draw Cutout (it draws various notches and is off by default). I just tried on a virtual device (Pixel 8 API 35) with that setting on and it crashed with what looks like the same errors.

logcats.zip

MikuAuahDark commented 1 month ago

Thanks for the log. I think I found the cause.