Repository navigation
Closed
Description
- The bug manifests itself as 'Script70' Error (error message "Access Denied" or "Permission Denied")
- If an SVG element is
<embedd src=some.svg>on a page and is then removed while an animation is still running in it - an exception is sometimes thrown fromd3.timer.tick()ord3.timer.stop(). To be more specific d3.timer stores state on a DOM node in the transition attribute and then tries todelete node.__transition__it ind3.timer.stop(). That will fail if the SVG element cannot be accessed (attribute access or assignments fail with an error). Ifd3.timer.tick()calls a function that does the animation (this could also be a custom attrTween) and it throws the timer continuation is stopped. - This is non recoverable by the application and will stop all concurrently runnning animations and will prevent all animations scheduled after that point!
- This is also not reliably preventable by the application as there is no way to synchronously stop an animation.
selection.interrupt().transition()andd3.timer.flush()all are asynchronous and thus the race condition between stopping the animation and IE killing of the SVG element remains. - We suspect that the IE js garbage collector is to blame for this, as the problem happens after varying intervals and can be triggered more easily if there is more activity in the DOM.
Possible solutions / workarounds:
- Keeping a reference to the embed DOM element seems to keep it alive - keeping a d3.selection of the SVG element (path, group, etc) inside it doesn't. This could mean that changing the way animations remember the elements they're working on could prevent this error.
- Catching and possibly discariding exceptions thrown from the handlers called by d3.timer.tick() and d3.timer.stop() so one erroneous SVG element doesn't kill all other d3 animations.
- Listen to DOM-removal events and internally and synchronously kill timers on the removed elements.
- Providing a solution to synchronously stop an animation. This could allow an app using d3 to work around this problem by stopping the animation before it removes the containing DOM element.
We would prefer a solution that doesn't require the d3 using app to include ie10/11 workarounds.
That being said, we think it would be very beneficial if we could force d3 to synchronously get rid of timeouts/ transitions/ animations/ ... on dom nodes. This would have helped us tremendously to track down/ work around this problem and would help d3 using applications to more easily work around similar issues when they are found in the future, until a real solution / fix is implemented in d3.
See this blocks gist for a demonstration/ reduction of this problem.
Activity
rbu commentedon Jan 13, 2015
There's an IE error report about this at https://connect.microsoft.com/IE/feedback/details/1086481
Not sure if they actually care.
mbostock commentedon Jan 13, 2015
d3.timer.flush is synchronous, not asynchronous.
mbostock commentedon Oct 21, 2015
Related #2415, d3/d3-timer#4.
mbostock commentedon Oct 22, 2015
If you know that there are no inactive transitions scheduled, you can synchronously stop any active transition by saying:
(If you want a big hammer, replace
selectionwithd3.select("*").)This will delete
node.__transition__on any selected node before timer.flush returns, which should avoid the error.However, this won’t work if you have an inactive transition scheduled, because selection.interrupt only interrupts the active transition and does not cancel scheduled transitions. You might think to try:
But this doesn’t quite work, either, because pre-empted transitions don’t clean themselves up until they start (whereupon they notice that
lock.active > idand immediately stop). So the deletion ofnode.__transition__still doesn’t happen until the pre-empted transition starts.Probably what we need here is a way for pre-empted transitions to be garbage collected immediately when the pre-empting transition starts. This way, the above code would do what we want. (And so would a selection.cancel method, or an improved selection.interrupt, as discussed in d3/d3-transition#9.) But in order to do that, I think we need a way to cancel a scheduled timer, and currently the only way to terminate a timer is to invoke its callback and have it return true. So I’ve filed d3/d3-timer#5.
Cancel pre-empted transitions synchronously.
mbostock commentedon Oct 25, 2015
In 3.5.7, the provided workaround will work as expected because cancelled transitions are now cleaned up synchronously:
In 4.0, we will change the behavior of selection.interrupt() to cancel any scheduled transitions in addition to interrupting the active transition, which I think is a more sensible default behavior. So in that case, you’d be able to say
selection.interrupt()and be done. See #2600 for the fix.mbostock commentedon Oct 25, 2015
Fixed in #2600, staged in #2591 for 3.5.7.