Defold player Crash on windows (SOLVED)


I’m using windows 7, with Defold 1.2.144.When my game is running,I press WIN+D to minimize all the window, then defold game crash:
I notice in the Defold editor that have the following log:


Hmm, probably a bug. Are you using a custom render script or any custom shaders?


Did you mean this?


Yes. Does it still crash if you use the render script in builtins when you minimize? (it’s not really a solution of course, but I’m curious if it is something in one of your shaders that is causing problems or if it’s the engine in general)


In my other projects, with builtin renderer, doesn’t crash.


Ok, so something in your render script or one of the shaders is causing the crash. Does it happen on only your computer or on others as well?

Still, the engine shouldn’t crash. @sven, @Mathias_Westerdahl and @jhonny.goransson might know if we could prevent the engine from crashing.


On another PC, that running windows10, will crash too.
And with the same crash log


You could try to comment out render.draw() calls from your render script one by one and see if you can pinpoint what part of your custom render script that is causing the problem. It would also be great if you could share the project with us ( so that we can try to reproduce it once everyone is back from vacation.


Do you only get the ”incomplete attachment” error when you minimize, or does it get logged immediately when you start your game? The error is related to your custom framebuffers / offscreen targets but shouldn’t crash the program. Could you post a complete log?


I comment out all the render.draw() and it still crash.


I’m sure that I get the error when I minimize.


I had pinpointed that when minimized, render.get_window_width() and render.get_window_height() will return 0


Ok, I will create a ticket in our bug tracker, but I also need a way to reproduce the bug. Can you provide me with a minimal repro case?


I found the following code will crash when both target_width and target_height is 0

local color_params = { 
		format = render.FORMAT_RGBA,
		width = target_width,
		height = target_height,
		min_filter = render.FILTER_LINEAR,
		mag_filter = render.FILTER_LINEAR,
		u_wrap = render.WRAP_CLAMP_TO_EDGE,
		v_wrap = render.WRAP_CLAMP_TO_EDGE

	local depth_params = { 
		format = render.FORMAT_DEPTH,
		width = target_width,
		height = target_height,
		u_wrap = render.WRAP_CLAMP_TO_EDGE,
		v_wrap = render.WRAP_CLAMP_TO_EDGE 

	return render.render_target(name, {[render.BUFFER_COLOR_BIT] = color_params, [render.BUFFER_DEPTH_BIT] = depth_params})


Ok, so you recreate the render target when the window is resized? In update() or via a window resize listener?


I think 0 is a reasonable “invalid” value when the window isn’t visible. Iirc, on windows it returns -32768 or something, but that’s going to be different on all platforms.

I’m guessing you get a window resize message before it crashes?


In update()


Ok, so maybe ignore creating the render target if width or height is 0?