Async loading and stability issues

Monkey Forums/Monkey Programming/Async loading and stability issues

Anatol(Posted 2012) [#1]
I'm testing async loading of images and sounds. Overall this works well and my app could benefit from this because it reduces load times between screens that can feel a bit long (especially on iPad3 with retina resolution).

It works reasonably well, but it is quite unstable. On iOS with async loading I often get EXC_BAD_ACCESS errors, usually in two locations:

in gc_assign():
template<class T,class V> void gc_assign( T *&lhs,V *rhs ){

	gc_object *p=dynamic_cast<gc_object*>(rhs);

	if( p && (p->flags & 3)==gc_markbit ){
		p->flags^=1;
		GC_REMOVE_NODE( p );
		GC_INSERT_NODE( p,&gc_queued_list ); // <------- Thread 1: EXC_BAD_ACCESS (code=1, address=0x443b4004)
	}

	lhs=rhs;
}


or in gc_collect():

	while( !GC_LIST_EMPTY( gc_queued_list ) && gc_marked_objs<tomark ){
		gc_object *p=gc_queued_list.succ;
		GC_REMOVE_NODE( p ); // <------- Thread 1: EXC_BAD_ACCESS (code=1, address=0x4)
		GC_INSERT_NODE( p,&gc_marked_list );
		gc_marked_bytes+=(p->flags & ~7);
		gc_marked_objs+=1;
		p->mark();
	}


I do check if resources are loaded completely, so that's not the issue I think.

A bit of background: the app is an interactive book, and occasionally/randomly crashes on page turns (when resources are loaded). The app always preloads all resources of the previous and next page and only allows page turns if all resources of the next/previous page have completed loading.

Does anyone know how I could avoid these crashes?

If I use "normal" loading I'm always extremely surprised how stable Monkey is. I can't manage to crash it at all.