[FIXED] Safe area in Android works... sometimes?

I’m so happy with the new Defold 1.12.2! It fixed indeed the gui.pick_node() issue but… Does it happen to you that the safe area works erratically?

Sometimes I open up my app and it works, sometimes (same app, no new build), I open it up and it ignores the safe area, with buttons being drawn where they shouldn’t. Am I missing something?

No safe area!

none

With safe area in any of your options you have a mismatch at the center point!

Sorry it doesn’t get corrected!

These tests were done in a 1920x1080px resolution.

If you have different resolutions, I recommend you do this Layouts

But I am using safe area (and immersive mode is on). Feels like safe are is not being found when launching the app?

But it’s funny because it’s the opposite error from the pick_node() issue! Now the button is inside the safe area, but I do have to click where it SHOULD be for it to work!?

That happens when example:

Your gui node has a resolution of 960x540…

And the device has a higher or lower resolution than your gui node!

There the position of your buttons is out of step and… :backhand_index_pointing_down:

It’s a bit tedious but with this you can create different layout measurements (960x540, 1920x1080, etc) the device itself detects the layout measurement!

I do have my layouts, that button is a child of the top-left corner node, which correctly places itself when resolution changes. And indeed, if I don’t use the safe area and simply place my button 100 pixels down from the top-left corner, it’s out of the device’s safe area and I can click it. But safe are should do that automatically, right? That’s its whole reason to exist :smiley:

I don’t think I’m explaining myself…

The issue is that safe area sometimes works (GUI is pushed out of the safe area and I can click on buttons thanks to that fix) and sometimes safe are does not work and GUI nodes are not pushed out of the safe are, as seen on the image I attached.

It works erratically. But when it works it works well now after the last update.

It is an intermittent failure :thinking:

Exactly. When I launch the app sometimes those buttons are properly pushed out of the safe area and I can click on them, sometimes they are not pushed VISUALLY, but if I tap where they should be it works.

Please, create a small project I can use for tests and open an issue GitHub · Where software is built

Provide as much info as possible about the phone you are testing on.

2 Likes

Here: Safe area node positions acting erratically · Issue #11979 · defold/defold · GitHub

Hope it sheds some light! Feels like a setup/start race of some kind. Sometimes it works one way, sometimes it works in a different way.

1 Like

I had some free time and did a bit of tinkering inside your project.

I can confirm the issue — every 3–4 launches the app behaves strangely.

I’m not entirely sure why this works, but removing the @render messages seems to fix the problem:

msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
msg.post("@render:", "use_camera_projection")

After removing these lines the issue no longer appears on my device.

2 Likes

Oh, would be nice to know why removing those solves the issue… and also why I still have them there. I probably can remove them safely in my projects!

There is a link in the issue to a build with my fix. It would be great if you could help test it:

I explained the issue here: Safe area node positions acting erratically · Issue #11979 · defold/defold · GitHub
It’s not related to the safe area logic, it’s a lua error in the render_script that appears because of msg.post("@render:", "use_camera_projection"

5 Likes

Yes, tested and working! Thank you a lot!

2 Likes