Crash in CanvasGraphics.playCommands()

I’m experiencing a crash in CanvasGraphics that is also reported here: https://github.com/openfl/openfl/issues/932

openfl_display_Graphics.__hitTest
$extend.__hitTest```

This is confirmed to be happening with OpenFL 3.6.0 in Chrome 49.0.2623.110; it has also been reported in unknown versions of Firefox, and possibly other versions of Chrome as well. 

To my knowledge, this crash is only seen in release; we have not yet encountered it in debug. It's not 100% reproducable -- clicking a given Sprite will not always cause the crash; however, we have a handful a cases where clicking different objects and performing various game actions in a particular order results in a fairly reliable repro rate.

I tested a naive fix to the issue where playCommands() early returns if bounds are null; however, this introduces a new problem where graphics become unclickable. For example, we have several instances in our game where we draw a darkened overlay behind some text via Sprite.graphics; clicking the overlay is supposed to dismiss it, but input is not registered for this object. 

Unlike the original crash, this new issue occurs in both debug and release. Similar to the original, it's not 100% reproducable, but we've found steps we can take to reproduce reliably.

Here is what the modified code looks like:

	private static function playCommands (commands:DrawCommandBuffer, stroke:Bool = false):Void {
		
		#if (js && html5)
		
		if ( graphics.__bounds == null )
		{
			trace( "Cannot playCommands; bounds were null." );
			// EARLY RETURN -- necessary data is null and will cause an exception
			return;
		}
		
		bounds = graphics.__bounds;


I've tried to track down where/why bounds might be getting set null, but can't locate the problem. Any thoughts or ideas?

Thank you =)
1 Like

As a quick update, we’re able to side step the problem by forcing shapeFlag to be false in Graphics __hitTest(). AFAICT, it doesn’t have a negative impact in our specific case, but this does mean only rectangular hit boxes for Graphics.