We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4256 - Android: SDL_GL_GetDrawableSize returns wrong size
Summary: Android: SDL_GL_GetDrawableSize returns wrong size
Status: WAITING
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: Other Android (All)
: P2 major
Assignee: Sylvain
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-09 14:22 UTC by dmuratshin
Modified: 2019-06-20 16:01 UTC (History)
2 users (show)

See Also:


Attachments
logcat (6.33 KB, text/plain)
2018-09-11 05:55 UTC, dmuratshin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dmuratshin 2018-09-09 14:22:28 UTC
SDL_GL_GetDrawableSize returns (1080, 1848) on some Full HD devices instead of (1080, 1920)
enabled flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_FULLSCREEN

notes:
1. It appeared after update to latest SDL from repository (from 8e9881eaf285ff25187158d51bc19077c52d4ccc  to efaed040cb06b935beaa5eeba31b74691fbfe32e).
2. I suppose this is somehow related with 470afa6b349ea6db14f0a131d37650de989479ee commit
3. SDL_WINDOW_FULLSCREEN I added especially for latest SDL because top status bar appeared after update
Comment 1 Ozkan Sezer 2018-09-09 21:50:17 UTC
I looked up the three commits you referenced and could not find any of
them in hg repository.
Comment 2 dmuratshin 2018-09-11 05:55:42 UTC
Created attachment 3302 [details]
logcat
Comment 3 dmuratshin 2018-09-11 06:02:36 UTC
sorry, hash values are taken from SDL mirror on github, example:
https://github.com/spurious/SDL-mirror/commit/411f83f9a04d6cc8ac55037f285651f3f41fee18

UPDATE:
I attached log file with logged everything including SDL_GL_GetDrawableSize.
error was reproduced on Amazon Kindle with real display resolution 1024x600, but SDL_GL_GetDrawableSize returned 1024x528 on start
Comment 4 Sam Lantinga 2018-09-17 06:01:46 UTC
I'm not sure that's actually a bug. It's returning the real drawable size, which is clipped by the OS navigation bar.

Sylvain, do you have any thoughts here?
Comment 5 dmuratshin 2018-09-17 06:50:32 UTC
but this "real drawable size" valid only for couple milliseconds then it changes to real fullscreen size.

How to initialize game components with real fullscreen size after start?
Comment 6 Sylvain 2018-09-17 07:42:38 UTC
I know the reported size is reduced if there is a status bar or a soft button bar, compared to the physical screen size.

But if you toggle the status bar, it should make sense the size is updated, as dmuratshin said.

I cannot have a look this week, but maybe next week.
Comment 7 Sylvain 2018-09-26 19:32:24 UTC
I have updated to the latest and also see the same behaviour. Maybe it's expected. Not sure how we should proceed.

some hint: 

1/ In SDLActivity.java, you can modify onCreate() so that it calls "setWindowStyle(true)" (and not "false"), so you always start in fullscreen.

2/ you use SDL_GL_GetDrawableSize(), instead there are
SDL_GetNumDisplayModes() and SDL_GetDisplayMode() which gives the fullscreen size anyway.
Comment 8 Sam Lantinga 2018-09-26 20:59:58 UTC
Sylvain, are you seeing this when you create the window fullscreen?
Comment 9 Sylvain 2018-09-27 09:09:20 UTC
Yes, 

I create a SDL window with SDL_WINDOW_FULLSCREEN.
the request for the fullscreen is done in SDL_CreateWindow(),
but the size are really updated when the android surfaceChanged() is executed, as it calls SDLActivity.onNativeResize().

here's my log, with calls to setWindowStyle().

SDL     : onCreate()
SDL     : setWindowStyle() fullscreen=false
SDL     : onResume()
SDL     : surfaceCreated()
SDL     : surfaceChanged()
SDL     : Window size: 918x1578
SDL     : Device size: 918x1632
SDL     : nativeResume()
SDL     : nativeRunMain()

Here, SDL_CreateWindow of size width : 918   height : 1632

SDL     : setWindowStyle() fullscreen=true

Calling SDL_GL_GetDrawableSize: 918 1578

SDL     : onWindowFocusChanged(): true
SDL     : surfaceChanged()
SDL     : Window size: 918x1632
SDL     : Device size: 918x1632

and after that, SDL_GL_GetDrawableSize: 918 1632
Comment 10 Sam Lantinga 2018-09-29 03:43:26 UTC
This should be fixed by this commit, can you please verify?
https://hg.libsdl.org/SDL/rev/d2e5d4520677
Comment 11 Sylvain 2018-10-01 20:31:53 UTC
It appears to fixed !
Comment 12 Sam Lantinga 2018-10-01 21:45:36 UTC
Great, thanks!
Comment 13 dmuratshin 2018-10-22 15:27:05 UTC
unfortunately not fixed completely :(
Now It can be reproduced on some devices and only at FIRST launch after install.

this patch does not fill me with confidence

try {
        SDLActivity.getContext().wait(250);
}
catch (InterruptedException ie) 
{
        ie.printStackTrace();
}

I don't know why but I can't extract full log on FIRST app launch after install (Huawei P Smart FIG-LX1)
Comment 14 dmuratshin 2018-10-22 16:56:40 UTC
only setWindowStyle(true) in modified onCreate helps to me (of course it is latest SDL from repo)
Comment 15 Sylvain 2019-01-24 07:54:18 UTC
@dmuratshin

Does it still happen with the latest SDL source version ?

Maybe the screen size should be initialized in onCreate, by calling:

   nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate());