Android screen size woes (11.2+)

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
pgimeno
Party member
Posts: 1909
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Android screen size woes (11.2+)

Post by pgimeno » Thu Oct 31, 2019 11:17 pm

I'm trying 11.3 on Android. I skipped 11.2 but I have tested it now and it behaves the same, except for the lack of love.window.getSafeArea() and usedpiscale.

conf.lua:

Code: Select all

function love.conf(c)
  c.window.usedpiscale = false
  c.window.fullscreen = false or true   -- change to test both cases
  c.window.fullscreenmode = "desktop" -- "exclusive" doesn't make a difference
end
main.lua:

Code: Select all

local lg, lw = love.graphics, love.window
local c = {window = {}}
love.conf(c)
if c.window.usedpiscale == false and lg.getNativeDPIScale then
  lg.setFont(lg.newFont(14*lg.getNativeDPIScale()))
end
lg.setLineStyle("rough")
lg.setBackgroundColor(0, 0, 1)

function love.draw()
  local x, y, w, h = lw.getSafeArea and lw.getSafeArea()
  local ww, wh = lg.getDimensions()
  -- Crossed box
  lg.line(0.5, 0.5, ww-0.5, wh-0.5)
  lg.line(0.5, wh-0.5, ww-0.5, 0.5)
  lg.rectangle("line", 0.5, 0.5, ww-1, wh-1)
  lg.print(string.format("%d.%d  %s %s %s %s %d %d", love.getVersion(), x, y, w, h, ww, wh), 0, 80)
end

function love.keypressed(k) return k == "escape" and love.event.quit() end
With this code, In all cases I get getSafeArea equal to 0, 0, getWidth, getHeight, but in fullscreen mode, with usedpiscale=false in my model the width is 2560 and in non-fullscreen it's 2413. The height doesn't change (1440). However:
  • In non-fullscreen, the notifications bar completely hides a part of the image.
  • In fullscreen, when the buttons hide, there is a black bar where the button bar would be.
Is love.window.getSafeArea() broken? Why can't we draw on the black area in fullscreen mode as other apps do?

Edit: 11.1 worked fine, in the sense that the app was in fullscreen by default and the area where the buttons were hidden was drawable.

nequals30
Prole
Posts: 4
Joined: Sun Sep 22, 2019 5:54 pm

Re: Android screen size woes (11.2+)

Post by nequals30 » Sat Nov 02, 2019 5:48 pm

I also have a screen size question related to Android 11.3, but it may be more basic.

I'm using the 'LÖVE for Android' app from the Play Store, which got updated to 11.3 this week, and for some reason the screen dimensions of my game have changed.

To set the dimensions, I was just doing this in conf.lua:

Code: Select all

function love.conf(t)
     t.window.width = 1920
     t.window.height = 1080
end
This worked fine in the previous version of the Android app (0.10.2), but now love.graphics.getWidth() returns 683 on the Android version rather than 1920, so everything is getting scaled wrong.

How do I fix this?

User avatar
pgimeno
Party member
Posts: 1909
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: Android screen size woes (11.2+)

Post by pgimeno » Sat Nov 02, 2019 6:37 pm

nequals30 wrote:
Sat Nov 02, 2019 5:48 pm
This worked fine in the previous version of the Android app (0.10.2), but now love.graphics.getWidth() returns 683 on the Android version rather than 1920, so everything is getting scaled wrong.
This is not a bug. 11.x uses units that are not pixels, but device-independent length units, so that using e.g. 20 units looks about the same size in all models regardless of resolution. For example, the default font uses height 14, but using it without DPI conversion makes it pretty much unreadable without a magnifying glass in many devices.

In 11.3+, you can disable this conversion by setting t.window.usedpiscale = false in love.conf. However, think twice before using a resolution that depends on your particular screen size, if you plan to redistribute the app. Also, if you use text, you'll have to do the scaling manually.

nequals30
Prole
Posts: 4
Joined: Sun Sep 22, 2019 5:54 pm

Re: Android screen size woes (11.2+)

Post by nequals30 » Sat Nov 02, 2019 7:22 pm

pgimeno wrote:
Sat Nov 02, 2019 6:37 pm
This is not a bug. 11.x uses units that are not pixels, but device-independent length units, so that using e.g. 20 units looks about the same size in all models regardless of resolution.
Ah. I knew I was missing something. Thanks for your help!

User avatar
AuahDark
Prole
Posts: 16
Joined: Mon Oct 23, 2017 2:34 pm
Contact:

Re: Android screen size woes (11.2+)

Post by AuahDark » Sun Nov 03, 2019 2:36 pm

I don't always online in the forum and prefer online in Discord, so sorry for the long delay.
pgimeno wrote:
Thu Oct 31, 2019 11:17 pm
[...] In all cases I get getSafeArea equal to 0, 0, getWidth, getHeight, but in fullscreen mode, with usedpiscale=false in my model the width is 2560 and in non-fullscreen it's 2413. The height doesn't change (1440). [...]
I wonder what's the return value of getSafeArea when you set usedpiscale=true. The width difference indicates your phone has very small notch? To be honest I don't have phone with virtual Android buttons (back, home, recent) so I can't really say much about this until I get new phone around January probably.
Profile. I don't always online in forum, so Discord is preferred.

User avatar
pgimeno
Party member
Posts: 1909
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: Android screen size woes (11.2+)

Post by pgimeno » Sun Nov 03, 2019 4:36 pm

AuahDark wrote:
Sun Nov 03, 2019 2:36 pm
I wonder what's the return value of getSafeArea when you set usedpiscale=true. The width difference indicates your phone has very small notch?
usedpiscale does not seem to affect this issue, it just behaves as expected. getSafeArea equals 0,0,getWidth,getHeight at all times, and getNativeDPIScale is 3.5, therefore with usedpiscale=true, the width reported by getSafeArea is 731 with fullscreen=true and 689 with fullscreen=false.

I've noticed that in full screen, it works fine sometimes. It tends to fail the first time, and it tends to correct itself if I press the soft home button then go to the task list and restore it. But sometimes it works fine the first time too.

In this thread, xNick1 is reporting somewhat similar issues: https://love2d.org/forums/viewtopic.php?f=4&t=86479

Given the symptoms, it seems clear that it's an Android system problem, but it would be nice if we had a workaround.

Here are some screenshots (not posted here because the images are big, to avoid disrupting the window size):

http://www.formauri.es/personal/pgimeno ... reen-size/

User avatar
AuahDark
Prole
Posts: 16
Joined: Mon Oct 23, 2017 2:34 pm
Contact:

Re: Android screen size woes (11.2+)

Post by AuahDark » Mon Nov 04, 2019 3:41 pm

Looks like code responsible to set the immersive mode is failing. I'll double check the code later, but no promise.

I'll release 11.3b when I fixed/workaround it.
Profile. I don't always online in forum, so Discord is preferred.

User avatar
pgimeno
Party member
Posts: 1909
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: Android screen size woes (11.2+)

Post by pgimeno » Tue Nov 05, 2019 10:26 am

Thanks for looking into it.

User avatar
AuahDark
Prole
Posts: 16
Joined: Mon Oct 23, 2017 2:34 pm
Contact:

Re: Android screen size woes (11.2+)

Post by AuahDark » Sun Nov 17, 2019 12:54 pm

I think I found the problem. There was some kind of code that conflicts with SDL. Mind if you test this APK?
Profile. I don't always online in forum, so Discord is preferred.

User avatar
pgimeno
Party member
Posts: 1909
Joined: Sun Oct 18, 2015 2:58 pm
Location: Valencia, ES

Re: Android screen size woes (11.2+)

Post by pgimeno » Sun Nov 17, 2019 2:46 pm

Thanks a lot! The non-fullscreen issue is fixed. Screen size and getSafeArea are both reported as 689x387 with usedpi=true and 2413x1356 when false. Reduced image with both screenshots is attached.

The intermittent fullscreen issue persists, though. I strongly suspect a system issue, since I'm still on Android 6.0. Weird thing is that LÖVE 11.1 did not have this issue.
Attachments
Screenshots_love-android-test.png
Screenshots_love-android-test.png (29.79 KiB) Viewed 1003 times

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests