Why is this crashing? Trying to understand render

Ok.
I’m trying to narrow down the render script just to understand the flow of it.
For some reason I have this weird crash if I try to draw any predicate with a meshes before drawing the tile-predicate.
Why is that happening?
For simplicity sake I’ve removed most other stuff in the script so the render is ugly, doesn’t use any depth-buffer for the model etc but:
THIS WORKS (shows both sprites and non depth checked models)

function update(self)
	render.set_depth_mask(true)
	render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})
	render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
	render.set_view(self.view)
	render.set_projection(vmath.matrix4_orthographic(
		-p.render_w * p.cam.scale + p.cam.pos.x, 
		p.render_w * p.cam.scale + p.cam.pos.x, 
		-p.render_h * p.cam.scale + p.cam.pos.y, 
		p.render_h * p.cam.scale + p.cam.pos.y, 
		-10000, 10000))

	render.draw(self.tile_pred)
	render.draw(self.model_pred)
  end

THIS FOR SOME REASON CRASHES THE ENGINE: ( draw model_pred before tile_pred )

function update(self)
	render.set_depth_mask(true)
	render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1, [render.BUFFER_STENCIL_BIT] = 0})
	render.set_viewport(0, 0, render.get_window_width(), render.get_window_height())
	render.set_view(self.view)
	render.set_projection(vmath.matrix4_orthographic(
		-p.render_w * p.cam.scale + p.cam.pos.x, 
		p.render_w * p.cam.scale + p.cam.pos.x, 
		-p.render_h * p.cam.scale + p.cam.pos.y, 
		p.render_h * p.cam.scale + p.cam.pos.y, 
		-10000, 10000))

    render.draw(self.model_pred)
	render.draw(self.tile_pred)
	
 end

EDIT: Crash log:
Process: dmengine [53951]
Path: /Users/USER/Library/Application Support/Defold/*/dmengine
Identifier: dmengine
Version: ???
Code Type: X86-64 (Native)
Parent Process: java [53053]
Responsible: dmengine [53951]
User ID: 501

Date/Time: 2017-06-21 18:40:09.133 +0200
OS Version: Mac OS X 10.11.6 (15G1217)
Report Version: 11
Anonymous UUID: 493EDFAA-3219-B705-4E83-B52B22267877

Sleep/Wake UUID: B4ED0A2A-6431-4BEA-9071-B79489952F43

Time Awake Since Boot: 280000 seconds
Time Since Wake: 5000 seconds

System Integrity Protection: enabled

Crashed Thread: 0 Dispatch queue: com.apple.main-thread

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Application Specific Information:
Assertion failed: (i < Size()), function operator[], file /Users/builder/ci/builds/engine-darwin-64-dev/build/tmp/dynamo_home/sdk/include/dmsdk/dlib/array.h, line 417.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8b0faf06 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff8ffc84ec pthread_kill + 90
2 libsystem_c.dylib 0x00007fff99cc76df abort + 129
3 libsystem_c.dylib 0x00007fff99c8edd8 __assert_rtn + 321
4 dmengine 0x0000000106fc01a5 dmRig::GenerateVertexData(dmRig::RigContext*, dmRig::RigInstance*, Vectormath::Aos::Matrix4 const&, Vectormath::Aos::Matrix4 const&, Vectormath::Aos::Vector4, bool, dmRig::RigVertexFormat, void*) + 11509
5 dmengine 0x0000000106eb3f73 dmGameSystem::RenderListDispatch(dmRender::RenderListDispatchParams const&) + 2227
6 dmengine 0x0000000106f6782a dmRender::DrawRenderList(dmRender::RenderContext*, dmRender::Predicate*, dmRender::NamedConstantBuffer*) + 1546
7 dmengine 0x0000000106f68f49 dmRender::ParseCommands(dmRender::RenderContext*, dmRender::Command*, unsigned int) + 649
8 dmengine 0x0000000106f6d844 dmRender::UpdateRenderScriptInstance(dmRender::RenderScriptInstance*) + 196
9 dmengine 0x0000000106e77b66 dmEngine::Step(dmEngine::Engine*) + 1318
10 dmengine 0x0000000106ed1606 dmGraphics::RunApplicationLoop(void*, void ()(void), int ()(void)) + 38
11 dmengine 0x0000000106e786e3 dmEngine::InitRun(dmEngineService::EngineService*, int, char**, void ()(dmEngine::Engine, void*), void ()(dmEngine::Engine, void*), void*) + 179
12 dmengine 0x0000000106e78567 dmEngine::Launch(int, char**, void ()(dmEngine::Engine, void*), void ()(dmEngine::Engine, void*), void*) + 119
13 dmengine 0x0000000106e78816 engine_main(int, char**) + 118
14 dmengine 0x0000000106e74ea4 start + 52

Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x00007fff8b0fbefa kevent_qos + 10
1 libdispatch.dylib 0x00007fff939c0165 _dispatch_mgr_invoke + 216
2 libdispatch.dylib 0x00007fff939bfdcd _dispatch_mgr_thread + 52

Thread 2:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 3:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 4:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 5:: log
0 libsystem_kernel.dylib 0x00007fff8b0fb10a __semwait_signal + 10
1 libsystem_c.dylib 0x00007fff99ce8d0f nanosleep + 199
2 libsystem_c.dylib 0x00007fff99ce8c02 usleep + 54
3 dmengine 0x0000000106ff39fa dmLogThread(void*) + 298
4 dmengine 0x00000001070047bc dmThread::ThreadStartProxy(void*) + 28
5 libsystem_pthread.dylib 0x00007fff8ffc599d _pthread_body + 131
6 libsystem_pthread.dylib 0x00007fff8ffc591a _pthread_start + 168
7 libsystem_pthread.dylib 0x00007fff8ffc3351 thread_start + 13

Thread 6:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 7:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 8:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 9:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 10:
0 libsystem_kernel.dylib 0x00007fff8b0fb5e2 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff8ffc5578 _pthread_wqthread + 1283
2 libsystem_pthread.dylib 0x00007fff8ffc3341 start_wqthread + 13

Thread 11:: CVDisplayLink
0 libsystem_kernel.dylib 0x00007fff8b0fadb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ffc675e _pthread_cond_wait + 821
2 com.apple.CoreVideo 0x00007fff8eb410d8 CVDisplayLink::waitUntil(unsigned long long) + 232
3 com.apple.CoreVideo 0x00007fff8eb40ed1 CVDisplayLink::runIOThread() + 511
4 com.apple.CoreVideo 0x00007fff8eb409a9 startIOThread(void*) + 147
5 libsystem_pthread.dylib 0x00007fff8ffc599d _pthread_body + 131
6 libsystem_pthread.dylib 0x00007fff8ffc591a _pthread_start + 168
7 libsystem_pthread.dylib 0x00007fff8ffc3351 thread_start + 13

Thread 12:: http
0 libsystem_kernel.dylib 0x00007fff8b0fadb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ffc6728 _pthread_cond_wait + 767
2 dmengine 0x0000000106fcfe69 dmConditionVariable::Wait(_opaque_pthread_cond_t*, _opaque_pthread_mutex_t*) + 9
3 dmengine 0x0000000106ff5bea dmMessage::InternalDispatch(unsigned long long, void ()(dmMessage::Message, void*), void*, bool) + 330
4 dmengine 0x0000000106f6efaf dmHttpService::Loop(void*) + 63
5 dmengine 0x00000001070047bc dmThread::ThreadStartProxy(void*) + 28
6 libsystem_pthread.dylib 0x00007fff8ffc599d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8ffc591a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8ffc3351 thread_start + 13

Thread 13:: http
0 libsystem_kernel.dylib 0x00007fff8b0fadb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ffc6728 _pthread_cond_wait + 767
2 dmengine 0x0000000106fcfe69 dmConditionVariable::Wait(_opaque_pthread_cond_t*, _opaque_pthread_mutex_t*) + 9
3 dmengine 0x0000000106ff5bea dmMessage::InternalDispatch(unsigned long long, void ()(dmMessage::Message, void*), void*, bool) + 330
4 dmengine 0x0000000106f6efaf dmHttpService::Loop(void*) + 63
5 dmengine 0x00000001070047bc dmThread::ThreadStartProxy(void*) + 28
6 libsystem_pthread.dylib 0x00007fff8ffc599d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8ffc591a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8ffc3351 thread_start + 13

Thread 14:: http
0 libsystem_kernel.dylib 0x00007fff8b0fadb6 __psynch_cvwait + 10
1 libsystem_pthread.dylib 0x00007fff8ffc6728 _pthread_cond_wait + 767
2 dmengine 0x0000000106fcfe69 dmConditionVariable::Wait(_opaque_pthread_cond_t*, _opaque_pthread_mutex_t*) + 9
3 dmengine 0x0000000106ff5bea dmMessage::InternalDispatch(unsigned long long, void ()(dmMessage::Message, void*), void*, bool) + 330
4 dmengine 0x0000000106f6efaf dmHttpService::Loop(void*) + 63
5 dmengine 0x00000001070047bc dmThread::ThreadStartProxy(void*) + 28
6 libsystem_pthread.dylib 0x00007fff8ffc599d _pthread_body + 131
7 libsystem_pthread.dylib 0x00007fff8ffc591a _pthread_start + 168
8 libsystem_pthread.dylib 0x00007fff8ffc3351 thread_start + 13

So I’ve turned inside-out on this one and it seems to be a very weird vodoo bug going on.
It seems like the crash is happening in many other really weird places so first of all, here is the assertion crash:
Assertion failed: (i < Size()), function operator[], file /Users/builder/ci/builds/engine-darwin-master/build/tmp/dynamo_home/sdk/include/dmsdk/dlib/array.h, line 417.

So for simplicity sake I only have one collada mesh which I drag around in different scenarios.
First of all I have two collections. Same model in the same gameobject with the builtin model material.
For one weird reason if dragging it into one collection that is bootstrapped, I immediately get this error when starting.
The other collection is loaded through a proxy and if the gameobject with the model is in there, no error. Viewed as it should.
I created a testproject with the model and it crashes if I have the object in the start collection.
Also crashed if its in a factory that is triggered.
The same mesh has been working perfectly fine in a previous project and then when I drag the model into the previous one it suddenly goes bat shit crazy!!

I place the weird model next to the working one. The working one has a script starting animations on itself when pressing a button. Suddenly the NEW MODEL starts animating without anyone calling it. Not only is it animating but playing another skeleton animation on itself.

So here is the bug:
On the model that crashes I have not set skeleton or animation. (did seem to be optional).
I really like to give you a project showcasing because it really hard explaining but it kinda just takes another random model skeleton and applies that to itself.
As soon as I set skeleton, I can draw model predicate before tile predicate (which also doesnt make sense)
It doesnt start an animation if another proper setup model is playing it’s animation.
It doesnt crash on specific collections.

I will clean up my mess here and prepare a nice little project if youd like to have

3 Likes

Wow, yeah, seems like a bug of some kind. A tiny sample project would probably help Sven and Andreas to find the bug. Thanks!

1 Like