Yeah, only iOS.
I had a custom renderscript which had this error, then switched to Rendercam because, you know, aaawesome. I haven’t tested with Orthographic, but likely it has the same issue.
Yeah, only iOS.
I had a custom renderscript which had this error, then switched to Rendercam because, you know, aaawesome. I haven’t tested with Orthographic, but likely it has the same issue.
Can you please log what render.get_window_width() etc return when the error happens? I’m guessing Defold/the OS reports 0 or something similar when returning the app from the background.
Sure! I modified Rendercam’s renderscript to print all values it gets from render. This means the line number of the error is no longer accurate. Please see the first message for a line number that correlates with Rendercam v1.0.2.
The last print before the error:
default 14:00:44.821013+0100 MyGame DEBUG:SCRIPT: rendercam.update() RenderScript: 0x01102df0d0
default 14:00:44.821070+0100 MyGame DEBUG:SCRIPT: render.get_width() 1124
default 14:00:44.821126+0100 MyGame DEBUG:SCRIPT: render.get_height() 2436
default 14:00:44.821182+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 750
default 14:00:44.821630+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 1624
default 14:00:45.816994+0100 MyGame 0x1122ddbd0 - ApplicationStateTracker: UISceneDidEnterBackground
default 14:00:45.817811+0100 MyGame 0x106101e18 - [pageProxyID=6, webPageID=7, PID=383] WebPageProxy::applicationDidEnterBackground: isSuspendedUnderLock? 1
default 14:00:45.818109+0100 MyGame 0x1122dfe80 - ApplicationStateTracker: UISceneDidEnterBackground
default 14:00:45.818252+0100 MyGame 0x1122decb0 - ApplicationStateTracker: UISceneDidEnterBackground
default 14:00:45.818366+0100 MyGame 0x10612c618 - [pageProxyID=22, webPageID=23, PID=388] WebPageProxy::applicationDidEnterBackground: isSuspendedUnderLock? 1
default 14:00:45.818567+0100 MyGame 0x1127d04b0 - ApplicationStateTracker: UISceneDidEnterBackground
default 14:00:45.819294+0100 MyGame 0x10612ea18 - [pageProxyID=28, webPageID=29, PID=389] WebPageProxy::applicationDidEnterBackground: isSuspendedUnderLock? 1
The error:
default 14:01:24.008550+0100 MyGame DEBUG:SCRIPT: rendercam.update_window() RenderScript: 0x01102df0d0
default 14:01:24.008651+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.008759+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.008815+0100 MyGame DEBUG:SCRIPT: rendercam.window.x 750
default 14:01:24.008867+0100 MyGame DEBUG:SCRIPT: rendercam.window.y 1624
default 14:01:24.008920+0100 MyGame DEBUG:SCRIPT: rendercam.update_window() 0 0
default 14:01:24.008972+0100 MyGame DEBUG:SCRIPT: vmath.matrix4_orthographic() 0 0 0 0 -1 1
default 14:01:24.009027+0100 MyGame DEBUG:SCRIPT: rendercam.update_window() RenderScript: 0x01102df0d0
default 14:01:24.009079+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.009135+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.009190+0100 MyGame DEBUG:SCRIPT: rendercam.window.x 0
default 14:01:24.009243+0100 MyGame DEBUG:SCRIPT: rendercam.window.y 0
default 14:01:24.009298+0100 MyGame DEBUG:SCRIPT: rendercam.update_window() 0 0
default 14:01:24.009351+0100 MyGame DEBUG:SCRIPT: vmath.matrix4_orthographic() 0 0 0 0 -1 1
default 14:01:24.009406+0100 MyGame DEBUG:SCRIPT: rendercam.update() RenderScript: 0x01102df0d0
default 14:01:24.009524+0100 MyGame DEBUG:SCRIPT: render.get_width() 1124
default 14:01:24.009666+0100 MyGame DEBUG:SCRIPT: render.get_height() 2436
default 14:01:24.009728+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.009780+0100 MyGame DEBUG:SCRIPT: render.get_window_width() 0
default 14:01:24.010005+0100 MyGame ERROR:SCRIPT: custom/rendercam.render_script:61: argument #1 contains one or more values which are not numbers: vmath.matrix4(nan, 0, 0, nan, 0, nan, 0, nan, 0, 0, -1, -0, 0, 0, 0, 1)
stack traceback:
[C]: in function 'set_projection'
custom/rendercam.render_script:61: in function <custom/rendercam.render_script:46>
default 14:01:24.010180+0100 MyGame ERROR:GRAPHICS: OpenGLClear(1108): gl error 1286
default 14:01:24.012115+0100 MyGame Resetting scope = 1, element = 0
It looks like you’re right! What’s the next step?
Does this also happen with the default render script?
You could try this Rendercam version: https://github.com/rgrams/rendercam/archive/ios_iconified.zip I just set it to skip updating the camera stuff if the window width/height are 0, 0. Unfortunately I don’t have an iOS device to test it on.
I’m guessing it’s only a problem with perspective cameras, and possibly fixed aspect ratio cameras, since with a width/height of 0, 0, the aspect ratio becomes NaN.
The iOS devices I have also don’t have this issue, regrettably. I’m trying to get a crash with an iPhone XR on the Xcode Simulator. I’ll report back.
I wasn’t able to get a crash with the Simulator, even though I was using the exact same iPhone image (iPhone XR). It isn’t possible to simulate the device going to sleep with the simulator, which leads me to believe the crash is directly related to that.
Yes! I built a completely blank project, with no extensions, and after coming back to life it crashed with the error below. The only change to the project was adding prints to the built in render script. It appears Rendercam is out of the loop.
default 11:07:14.644812+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.update.init() RenderScript: 0x010d585610
default 11:07:14.644870+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 750
default 11:07:14.644927+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 1624
default 11:07:14.644984+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:14.645040+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:14.645096+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.render_script.get_projection() RenderScript: 0x010d585610
default 11:07:14.645152+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 750
default 11:07:14.645207+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 1624
default 11:07:14.645265+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:14.645319+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:14.645375+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.render_script.stretch_projection() -1 1
default 11:07:14.645431+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 750
default 11:07:14.647609+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 1624
default 11:07:14.648149+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:14.648318+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:15.734287+0100 MyGameTestingSleepCrash failed to make complete framebuffer object 8cd6
default 11:07:16.837642+0100 MyGameTestingSleepCrash failed to make complete framebuffer object 8cd6
default 11:07:32.588996+0100 MyGameTestingSleepCrash HTHangEventCreate: HangTracing is disabled. Not creating a new event.
default 11:07:32.589533+0100 MyGameTestingSleepCrash Call host has no calls
default 11:07:32.600483+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.update.init() RenderScript: 0x010d585610
default 11:07:32.600563+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 0
default 11:07:32.600622+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 0
default 11:07:32.600681+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:32.600824+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:32.601157+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.render_script.get_projection() RenderScript: 0x010d585610
default 11:07:32.601223+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 0
default 11:07:32.601413+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 0
default 11:07:32.601612+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:32.601974+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:32.602061+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: default.render_script.stretch_projection() -1 1
default 11:07:32.602121+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_width() 0
default 11:07:32.602206+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_window_height() 0
default 11:07:32.602272+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_width() 1124
default 11:07:32.602340+0100 MyGameTestingSleepCrash DEBUG:SCRIPT: render.get_height() 2436
default 11:07:32.602396+0100 MyGameTestingSleepCrash ERROR:SCRIPT: custom/default.render_script:125: argument #1 contains one or more values which are not numbers: vmath.matrix4(inf, 0, 0, nan, 0, inf, 0, nan, 0, 0, -1, -0, 0, 0, 0, 1)
stack traceback:
[C]: in function ‘set_projection’
custom/default.render_script:125: in function <custom/default.render_script:94>
default 11:07:32.602843+0100 MyGameTestingSleepCrash ERROR:GRAPHICS: OpenGLClear(1108): gl error 1286
default 11:07:32.605648+0100 MyGameTestingSleepCrash INFO:CRASH: Successfully wrote Crashdump to file: /var/mobile/Containers/Data/Application/4DE1C419-65B0-4C57-98B0-18C2EC3BEDC6/Library/Application Support/Defold/_crash
This issue is holding up the iOS release of one of my games. Any idea of how to fix or mitigate it?
Yes, the problem is that the window width/height is reported as 0 and that results in an invalid project matrix:
render.set_projection(vmath.matrix4_orthographic(0, render.get_window_width(), 0, render.get_window_height(), -1, 1))
Values will be nan
(not a number) in the case of window width/height being 0. Quick fix is to check for this and not render anyting:
function update(self)
local ww = render.get_window_width()
local wh = render.get_window_height()
if ww == 0 or wh == 0 then
return
end
I will look into this and see what we can do to prevent it.
I have tested this on a new build. The crash still happens, but there is no Lua error this time. See below.
I believe this is the fix @ross.grams added above, and although the Lua error is fixed, the crash still happens. This is the log with Rendercam ignoring 0 values: log.txt (565.6 KB)
Edit: Could it be this line that’s causing the crash?
default 13:06:38.908632+0100 MyGame ERROR:GRAPHICS: OpenGLClear(1108): gl error 1286
Is it an actual crash out of the application or a logged error? I don’t see an actual callstack or other indication of a proper hard crash.
Yes, the app closes down. When restarted it doesn’t resume, it’s a fresh restart.
Sorry, the log was filtered to the game process only. Here is an unfiltered humongous log: log2.txt (1.6 MB)
The OpenGLClear error from above is on line 12,328. Yeah, it’s a big file.
I see. I’m not sure this something new though. Is the iPhone XR the only device that returns width/height 0 when returning?
It’s the only device we’re seeing the problem on. iPhone 11 Pro - fine.
Another game I’ve been working on was soft released recently. it is using a vanilla implementation of the Orthographic extension. I just checked the errors I catch and send to GameAnalytics:
orthographic/render/helper.lua:75: argument #1 contains one or more values which are not numbers: vmath.matrix4(inf, 0, 0, nan, 0, inf, 0, nan, 0, 0, -1, -0, 0, 0, 0, 1) stack traceback: [C]: in function 'set_projection' orthographic/render/helper.lua:75: in function 'set_screen_view_projection' orthographic/render/orthographic.render_script:50: in function <orthographic/render/orthographic.render_script:21>
This is on iOS. Android is reporting no similar errors. This is likely to be an issue on all iOS games using Rendercam/Orthographic and the latest Defold build.
Aside from patching the Orthographic extension, is there something else I can do?
This issue is related to the latest change for the iconified event, and the OS reports a window size of (0,0).
I think @britzl has an upcoming fix for this.
I’ve fixed this in the Orthographic camera (release v 2.10.1)
Fantastic! Will try it out for the next release.
Update: Most errors are gone, happy days! I only get this one reported now with Orthographic v2.10.1:
orthographic/render/helper.lua:61: argument #1 contains one or more values which are not numbers: vmath.matrix4(inf, 0, 0, nan, 0, inf, 0, nan, 0, 0, -1, -0, 0, 0, 0, 1)
stack traceback:
[C]: in function 'set_projection'
orthographic/render/helper.lua:61: in function 'set_screen_view_projection'
orthographic/render/orthographic.render_script:47: in function <orthographic/render/orthographic.render_script:21>
Update: The game is now released and a few thousand of the above errors happen a day. I imagine it’s a silent error, because it doesn’t seem to produce one-star reviews, but maybe the extension could be updated for tidiness’ sake?
Done! New version which handles window width and height being zero: https://github.com/britzl/defold-orthographic/releases/tag/2.10.2