defold / editor2-issues

DEPRECATED
44 stars 4 forks source link

profiler.enable_ui() cause engine halt at release build #2648

Closed selimanac closed 4 years ago

selimanac commented 5 years ago

Engine halts when profiler.enable_ui(false) called at release build (Tested on MacOS, iOS, Windows)

function init(self)
    profiler.enable_ui(false)
    -- halts here. msg.post never reached.
    msg.post("@render:", "clear_color", {color = vmath.vector4(255 / 255, 0 / 255, 0 / 255, 0)})
end
AGulev commented 4 years ago

There is no profiler module in release mode. That means you try to call (nil).enable_ui(false) and get a Lua error there. It is expected behavior.

selimanac commented 4 years ago

That means you try to call (nil).enable_ui(false) and get a Lua error there. It is expected behavior.

Hi @AGulev

It isn't throw error, actually it should. This is why I opened this issue: It completely blocks the thread, no error no warning, none, game just stops(only on release bundle).

Is this a expected behavior? If so OK, but not for me. Anyone can forget to remove this simple function from his code and they can pull their hair to find what cause a engine halt on release build.

Example is attached. Simply bundle it for target platform and run.

profiler.zip

AGulev commented 4 years ago

I'll take a look today evening.

AGulev commented 4 years ago

I've checked your example and modified it a bit by adding label and error handler:

function init(self)
    sys.set_error_handler(function(source, message, traceback) 
        label.set_text("#label", message)
    end)
    profiler.enable_ui(false)
    msg.post(".", "acquire_input_focus")
    msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
    go.animate("/go", "position.x", go.PLAYBACK_LOOP_PINGPONG, 850, go.EASING_INBOUNCE, 1)
end

Here is result

image

As I told you this is just a Lua error. We don't have profiler module in release mode, so we can't call this function. That's how Lua works: execution in progress until the first error. You can't see the error just because you are in release mode and don't have a connected Editor or some other way to see logs, for example, DefCon https://github.com/britzl/defcon

If you write any Lua code with an error in the first line of the function result will be the same (even in debug mode), for example:

function init(self)
    -- we don't have random_name table with some_function - that means we will have Lua error here
        -- and everything in this function after the error will not be called.
    random_name.some_function()
    msg.post(".", "acquire_input_focus")
    msg.post("@render:", "use_fixed_fit_projection", { near = -1, far = 1 })
    go.animate("/go", "position.x", go.PLAYBACK_LOOP_PINGPONG, 850, go.EASING_INBOUNCE, 1)
end

function on_input(self, action_id, action)
    if action_id == hash("touch") and action.pressed then
        print("Touch!")
    end
end

Project: profiler.zip

AGulev commented 4 years ago

I'm not sure what can we do here. We already have info in Profiling manual that this module is available only in Debug:

Defold includes a set of profiling tools that are integrated with the engine and the build pipeline. These are designed to help find problems with performance and memory usage. The built-in profilers are available on debug builds only.

That's why I closed this issue and told you this is expected behavior.

selimanac commented 4 years ago

If you write any Lua code with error in the first line of the function result will be the same (even in debug mode), for example:

I definitely doesn't aware of that. I thought it is only related to profiler. I get it now, thank you. This not really important for me, I was thinking the newcomers.