godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.07k stars 21.18k forks source link

Inconsistent scene switching behavior between X11(Linux) and Android #1133

Closed scroolewse closed 8 years ago

scroolewse commented 9 years ago

I tried to reduce this issue down to a testcase located here: https://www.dropbox.com/s/0taiy1hu73l4pou/SceneSwitchBug.zip?dl=1

And this was tested with the most recent committ in github https://github.com/okamstudio/godot/commit/6b106b319b0b4c9436a992bf26c88d93180905e9

On Linux: I have a button that shows/hides a panel. Clicking on the showing panel hides it (via _input_event(event)). I set _set_process_unhandled_input(true) so that it either the hides a showing panel or moves on to scene_b.

And that seems to work for me.

On Android: If I click anywhere on the screen to trigger _unhandled_input(event), it switches to scene_b (as expected) but the StreamPlayer does not play. And the following shows up in the logcat.

01-06 17:31:16.812: I/godot(3614): ERROR: free: Method/Function Failed. 01-06 17:31:16.812: I/godot(3614):  At: servers/visual/visual_server_raster.cpp:4173. 01-06 17:31:16.812: I/godot(3614): ERROR: free: Method/Function Failed. 01-06 17:31:16.812: I/godot(3614):  At: servers/visual/visual_server_raster.cpp:4173.

When I press the green "pop-up" button, instead of showing the panel, it switches to scene_b and starts playing the music. And the following shows up in the logcat.

01-06 17:33:05.812: I/godot(3863): ERROR: free: Method/Function Failed. 01-06 17:33:05.812: I/godot(3863):  At: servers/visual/visual_server_raster.cpp:4173.

akien-mga commented 9 years ago

Can you still reproduce this issue with the current master branch/nightly builds?

scroolewse2 commented 8 years ago

I can mostly repro this issue again on today's commit 662ed9c.

Behavior on Linux is exactly the same as before.

On Android, when tapping anywhere on the screen to trigger _unhandled_input(event), StreamPlayer does play now. However, pressing the green "pop-up" buton, still incorrectly causes a switch to scene_b.

scroolewse2 commented 8 years ago

After the StreamPlayer fix, the only issue left was that the "pop-up" button incorrectly caused a switch to scene_b. I finally figured out that on Android, a touch sends two input events (one for the mouse button and one for touching the screen) to _unhandled_input(event). This can be demonstrated on X11 by enabling "Touchscreen Emulation" in the project settings.

Accounting for the extra input event fixed the problem. Phew!

I consider this issue solved, please go ahead and close it :-D