One android test device, two different resolutions bug?

Hello,

I am facing a very frustrating issue with my game.

I set a dummy app to match the display info of my game. I build contentless debug builds for both apps.

When I run the dummy app AND my app in dummy apps bundle, I get these dimensions:

// Width / Height Density: 3.0

DEBUG:SCRIPT: DIMS: 1136 640 , 2400 1080

and when I run both apps in my game’s bundle, I get these dimensions:

// Width / Height Density: 2.25

DEBUG:SCRIPT: DIMS: 1136 640 , 1800 810

For the life of me, I cannot figure out why this is happening. It is affecting my Banner Ads as the banner dimensions returned are incorrect.

I also wanted to mention that this issue happens on all the android devices I load the debug apps on. I am testing on Samsung and LG devices. All produce similar resolution differences.

This might add more context. This is how I retrieve the size information. So the window size is what appears to be the value that is causing me issues.


data.screenWidth, data.screenHeight = sys.get_config_number("display.width"), sys.get_config_number("display.height") 	
	data.windowWidth, data.windowHeight = window.get_size() 
print ("DIMS: ", data.screenWidth, data.screenHeight, data.windowWidth, data.windowHeight)
```

Okay. After 3+ days of research, stripping down my folder structure, string libraries, etc, I have found the only thing that actually makes my game change from the correct resolution numbers to the broken numbers.

My package name affects what is happening and I don’t know why.

my package name is something like com.xxx.shiboriLand.

If I run the game, the window.get_size() code is incorrect.

if I change the package name to anything else or or even com.xxx.shiboriLan, window.get_size() behaves correctly. What can be causing this issue?

Is it because my game is already active on google play store and old data is automatically loaded and used?

These are the packages I use:

dependencies#0 = https://github.com/subsoap/defsave/archive/refs/tags/v1.2.6.zip
dependencies#1 = https://github.com/defold/extension-iap/archive/refs/tags/8.4.0.zip
dependencies#2 = https://github.com/defold/extension-gpgs/archive/refs/tags/5.0.0.zip
https://github.com/AGulev/DefVideoAds/archive/refs/tags/4.19.2.zip

@AGulev @britzl , sorry to tag and bother you but I am hoping that maybe your expertise can be of help.

please take a look https://developer.android.com/games/optimize/adpf/gamemode/gamemode-interventions

Android may apply downscale to the app (it based on package name)

1 Like

I honestly don’t know what’s going on either. I’m also not entirely sure I understand exactly what it is you are testing.

Is this a requirement for the problem to occur?

1 Like

Banner dimensions returned by the extension are in Defold screen-space pixels, matching window.get_size(). You do not need to apply Android density or compensate for the 75% downscaling. If you need to move a GUI node by the banner height, either use gui.get_screen_position()/gui.set_screen_position() directly, or convert the screen-space distance to the node’s local coordinates using gui.screen_to_local(). This also handles the node’s parents, anchors, adjust mode, and current GUI layout.

1 Like

These values:

sys.get_config_number("display.width")
sys.get_config_number("display.height")

are the logical resolution configured in game.project
in your case 1136 × 640. They do not report the device’s physical resolution.

window.get_size() returns the rendering surface Android provides to Defold.

Android and device manufacturers can apply Game Mode optimizations per package. This explains why changing only the package name changes the result.

You can check for package-specific settings using:

adb shell device_config get game_overlay com.xxx.shiboriLand
adb shell dumpsys platform_compat

In the second output, look for your package name and these Android compatibility changes:

DOWNSCALED       168419799
DOWNSCALE_75     189969779

Also check whether the device’s Game Booster or Game Mode has a resolution or battery-saving option enabled for this game.

Banners: the extension returns the banner dimensions in Defold screen-space pixels, matching the coordinate system used by window.get_size(). You should not apply the Android density or the 0.75 factor yourself.

If you want to move a GUI node by the banner height, you can work directly in screen space:

local node = gui.get_node("content")
local position = gui.get_screen_position(node)

position.y = position.y + message.height

gui.set_screen_position(node, position)

If you need the banner height in the node’s local coordinate system. For example, to resize a node or use gui.set_position()—convert the screen-space distance using gui.screen_to_local():

local function screen_height_to_local(node, screen_height)
    local p0 = gui.screen_to_local(node, vmath.vector3(0, 0, 0))
    local p1 = gui.screen_to_local(node, vmath.vector3(0, screen_height, 0))
    return p1.y - p0.y
end

local node = gui.get_node("content")
local banner_height = screen_height_to_local(node, message.height)

local position = gui.get_position(node)
position.y = position.y + banner_height
gui.set_position(node, position)

This conversion takes the node’s parents, anchors, adjust mode, and current GUI layout into account.

In short, it doesn’t matter what Android returns. You just need to convert values from screen (window) space into GUI space. For that, it doesn’t matter exactly which values you get; you just need to know which space they are in.

4 Likes

Thank you, and yes, the banner code works perfectly. I suppose it should have been worded differently.

Due to the res scaling, I suppose, the banner adjustment calculations i use is in correct.

For instave, I divide window_height by game.project_height. That value is then multiplied by the banner height (320x50).

I then adjust my top bar gui by this value. With the package name change, it works flawlessly. But my game must be getting down scaled.

No it is not. I am simply testing the functionality and Ads support. I believe @AGulev may have hit on what is happening to my project. I will have to figure it all out with the information provided.

1 Like

This is an awesome response. I truly appreciate all the help you and the Defold team have provided me.

Thank you very much.

1 Like

Well, I guess I am back to the drawing board.

Maybe I need to just remove the banners all together. Nothing is working and my device is not using ny downscaled resolution as far as test and adb go.

Update: I tried a different (LG) device and it works fine. But my samsung device produces the below image.