Hollywood crash while calling AsyncDrawFrame()

Report any Hollywood bugs here
Post Reply
User avatar
midwan
Posts: 74
Joined: Sun Jun 19, 2016 1:15 pm
Location: Sweden

Hollywood crash while calling AsyncDrawFrame()

Post by midwan »

I came across a crash which I can recreate every time, under certain conditions:

- Enable Layers
- Start application, display a Brush (on its own layer)
- Load an Anim using LoadAnim()
- Call PlayAnim() and store it in a variable
- Call RemoveLayer(1) to remove the brush layer
- Have an interval to draw the next frame when there is an Anim loaded and a "playing" variable is set to True (i.e. Play button was clicked). The next frame is drawn using AsyncDrawFrame()

Using the above sequence, it seems that as soon as AsyncDrawFrame() is called, Hollywood hits an unhandled exception and it closes down.
Specifically, this exception:

Code: Select all

Unhandled exception at 0x00450914 in Hollywood.exe: 0xC0000005: Access violation reading location 0x00000028.
I tracked this down to the order of the sequence, when RemoveLayer(1) is called. If it's called after PlayAnim(), you get the crash. If it's called before PlayAnim(), it works as expected.

I understand that it may be a logical error to try and remove a Layer that may be used or is the last one you have, but either way it should never crash Hollywood itself if you do that. :)

Code snippets below:

This causes a crash:

Code: Select all

@BRUSH 10, "data/cover.png"
@DISPLAY {Color = #BLACK, Title = "AnimPlayer", Sizeable = True, Layers = True}
DisplayBrush(10, #CENTER, #CENTER)
Local f$ = "filename.anim"
LoadAnim(1, f$, {FromDisk = True})
playingAnim = PlayAnim(1, 0, 0, {Speed = #DEFAULTSPEED, Times = 1, Async = True})
RemoveLayer(1)

...

Case "Interval":
If Not IsNil(playingAnim) And playing = True
done = AsyncDrawFrame(playingAnim)
EndIf
Whereas this, does not:

Code: Select all

@BRUSH 10, "data/cover.png"
@DISPLAY {Color = #BLACK, Title = "AnimPlayer", Sizeable = True, Layers = True}
DisplayBrush(10, #CENTER, #CENTER)
Local f$ = "filename.anim"
LoadAnim(1, f$, {FromDisk = True})
RemoveLayer(1)
playingAnim = PlayAnim(1, 0, 0, {Speed = #DEFAULTSPEED, Times = 1, Async = True})

...

Case "Interval":
If Not IsNil(playingAnim) And playing = True
done = AsyncDrawFrame(playingAnim)
EndIf
I'm using Hollywood 6.1, the app uses RapaGUI and the sample Anim I loaded to play around with was an Anim8L.

If anything further is required, I'd be happy to make it available to assist narrowing this down.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hollywood crash while calling AsyncDrawFrame()

Post by airsoftsoftwair »

You're right. This is first and foremost an error in your script because you're trying to update a layer that is gone. But of course, Hollywood's philosophy is to run all scripts in a sandbox so there should always be a clean exit, even if a script does something evil. I'll fix this in Hollywood so that it errors out cleanly in this case.
User avatar
airsoftsoftwair
Posts: 5433
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Hollywood crash while calling AsyncDrawFrame()

Post by airsoftsoftwair »

I was wrong, it isn't an error in your script because you are removing the brush layer which is of course perfectly allowed. The bug has been fixed now.

Code: Select all

- Fix: Removing a layer behind a layer associated with an asynchronous draw object allocated by
  PlayAnim() resulted in crashes in all further calls to AsyncDrawFrame()
User avatar
midwan
Posts: 74
Joined: Sun Jun 19, 2016 1:15 pm
Location: Sweden

Re: Hollywood crash while calling AsyncDrawFrame()

Post by midwan »

Great, thanks! :)
Post Reply