Animating an object's transform while using filters to animate the object concurrently causes the hosting process to crash.
Numbered Steps to Reproduce Problem:
1) Use this test environemnt or the source below
2) Use the CreateObj() verb until the process crashes
Code Snippet (if applicable) to Reproduce Problem:
world
fps = 25 // 25 frames per second
icon_size = 32 // 32x32 icon size by default
maxx=5
maxy=5
maxz=1
view = 6 // show up to 6 tiles outward from center (13x13 view)
atom/var/tmp/dashFilter
atom/icon = 'test.dmi'
turf/icon_state = "turf"
mob
verb
/**
* Using this verb several times will reproduce the conditions that
* caused the crash. For reasons I do not know, the bug does not always
* occur when the verb is invoked. However, using it several times
* seems to reliably trigger a crash.
*/
CreateObj()
var/obj/o = new(loc)
o.AnimationCrash()
obj
proc
AnimationCrash()
dashFilter = filter(type="motion_blur", x=3, y=1, loop=-1)
filters = dashFilter
animate(dashFilter, time=2)
// The bug only seems to manifest while motion blurred object is
// animated to spin
var/willSpin = TRUE
if(willSpin)
var/t = 1
var/savedTransform = src.transform
animate(src, transform = turn(savedTransform, 120), time = t, loop = -1)
animate(transform = turn(savedTransform, 240), time = t)
animate(transform = savedTransform, time = t)
sleep(2)
animate(dashFilter, x=0, y=0, time=2)
sleep(2)
filters=null // Commenting out this line seems to stop the crash
// Remove the objects from the screen
sleep(10)
del(src)
Expected Results:
A motion blurred spinning object
Actual Results:
A motion blurred spinning object that tends to crash Dream Daemon
Does the problem occur:
Every time? Or how often?
It seems to occur after a random number of times the AnimationCrash() is invoked.
In other games?
The above code is an isolated code snippet from a larger project.
In other user accounts?
On other computers?
I've tested this running on an Ubuntu Virtual Machine and on Windows 10 Home Edition. Neither environment prevents Dream Daemon from crashing in those cases. The Ubuntu VM sometimes provides the following error message:
BUG: Crashing due to an illegal operation!
However, this error message does not always appear. Sometimes the process will hang until killed.
When does the problem NOT occur?
The problem does not seem to occur when the obj is not animated to spin or when the filters list is not set to null.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Workarounds:
Your code however is broken. There are two problems. First, loop is not a valid argument to filter(); it's an animation argument. Second, calling animate() on dashFilter won't work, because it's a raw filter and isn't assigned to any object. The way to animate the filter is to call animate() on filters[1], which references the first filter belonging to src.
I believe that calling animate() with the correct argument will eliminate your crash. Obviously I still have a bug to fix though.