subsoap/defos

Toggling fullscreen in update() of gui script creates error

8bitskull opened this issue · 5 comments

Hi! This is asvegren from the Defold forums.

First of all - massive thanks for this amazing extension.

I have encountered an issue using defos.set_fullscreen(bool_value) and defos.toggle_fullscreen(). I have a gui component that deals with various game settings, including full screen. I noticed that toggling full screen interrups the completion of the rest of the update() cycle in my gui script.

When I click the fullscreen button in my script (which immediately triggers defos.toggle_fullscreen()), the next gui node accessed using gui.get_node() is not found, yielding an error like this:
ERROR:SCRIPT: /HUD/settings/settings.gui_script:19: No such node: scaling_bg

scaling_bg in this example isn't actually deleted however.

I've realised that I don't have any issue if I just move my fullscreen toggle check to the end of the update() cycle (thereby not accessing any more gui nodes), however I thought I would raise this just in case it's important for anyone else.

Hmm, that is quite surprising behaviour to be honest! I'm not sure what could be causing it. I guess you could post a message to yourself when you detect the click in on_input() and handle the message in on_message() where you call triggers defos.toggle_fullscreen().

I agree with @britzl you probably will be able to deal with this best by sending a message to itself or another script to do the toggling on getting the message to avoid any interrupt. But you should also try to make a minimal reproducing example for us to test and see what's really going on.

What OS is this happening on?

Thanks for the suggestions on sending messages to shift where the call happens.

I am getting this error on Windows 7.

I tried making a reproducing example, but am failing to do so. The example I am pasting below is indicative of what happens in my main project and should trigger the error, but doesn't. I suppose that means either I'm misunderstanding the cause or there is something else interacting in my main project.


function init(self)
	full_toggled = false
end

function update(self, dt)

	if not full_toggled then

		print("getting:", gui.get_node("box1"))

		defos.toggle_fullscreen()

		full_toggled = true

		print("getting:", gui.get_node("box2"))

	end

end

@8bitskull is this still happening?

I reset the offending script to its original configuration and can no longer reproduce the issue.