Skip to content

TransitionEnd event can include nodes that have been GCed #14972

Closed

Description

@jdm

https://github.com/servo/servo/commits/5d3847dddc9bb7907abfa5d38a7927d6c656fbc1/components/layout/animation.rs sends an asynchronous message to the script thread that contains an UnsafeNode value. When the script thread processes the message, it casts the unsafe node to a DOM node and tries to use it. If the node has been GCed since the layout event that caused the message to be sent, this is a crash.

I propose fixing this in the same way that #14962 deals with asynchronous operations involving DOM nodes - collect them during layout and have the script thread retrieve them immediately to prevent risk of them being GCed.

I hit this in a debugger while running the TodoMVC benchmark: https://lhorie.github.io/todomvc-perf-comparison/todomvc-benchmark/

Activity

  1. added
    A-content/script
    I-crash
    I-safety
    on Jan 11, 2017
  2. KiChjang commented on Jan 11, 2017

    @KiChjang
    Contributor

    This looks like it's something that I ought to have fixed but didn't because I assumed that a layout node always have a valid reference to its underlying DOM node. Could you expand on how the "collection during layout" and "retrieving in script thread" works?

  3. jdm commented on Jan 11, 2017

    @jdm
    MemberAuthor

    The easiest way I've found is to create a layout RPC mechanism to retrieve a list of nodes, and invoke that right after reflow completes in script. Meanwhile layout populates the list via a member of the various context objects that are passed around. Of course, this only works if the reflow is initiated from script. If something's else is driving the animations in layout, we need a different solution.

  4. jdm commented on Jan 12, 2017

    @jdm
    MemberAuthor

    I can often hit this on the benchmark linked above if I disable the Ractive, Likely, and Mithril suites.

  5. jdm commented on Jan 31, 2017

    @jdm
    MemberAuthor

    I'm hitting this repeatedly when creating a blank document on docs.google.com with #15082 applied (and other related document.open/document.write hacks to allow page loading to progress).

  6. jdm commented on Jan 31, 2017

    @jdm
    MemberAuthor

    Blocks #13942.

  7. added 3 commits that reference this issue on Apr 7, 2017
    8b5c8b8
    bef0a38
    39f1fc5
  8. added a commit that references this issue on May 15, 2017
    fa251ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/scriptA-layout/animationsI-crashI-safety

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions