This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10878 - Structured clone algorithm should be updated to support Directed Acyclic Graphs
Summary: Structured clone algorithm should be updated to support Directed Acyclic Graphs
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: pre-LC1 HTML5 spec (editor: Ian Hickson) (show other bugs)
Version: unspecified
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://dev.w3.org/html5/spec/common-d...
Whiteboard:
Keywords:
Depends on:
Blocks: 10877
  Show dependency treegraph
 
Reported: 2010-09-30 17:28 UTC by Adrian Bateman [MSFT]
Modified: 2010-10-06 22:41 UTC (History)
9 users (show)

See Also:


Attachments

Description Adrian Bateman [MSFT] 2010-09-30 17:28:11 UTC
See bug 10877 (http://www.w3.org/Bugs/Public/show_bug.cgi?id=10877)

The current algorithm converts DAGs into trees, which isn't the most appropriate "clone" of object data. The algorithm should be modified to clone DAGs correctly (e.g. Modifying the algorithm to re-use "memory" instead of copying into "new memory" or to assign "new memory" back to "memory" as the recursion unwinds).

If the purpose of the algorithm is not support DAGs then it should throw just as it does for cyclic graphs.
Comment 1 Ian 'Hixie' Hickson 2010-09-30 19:02:02 UTC
The original intent was to make the algorithm essentially do the same as one would get if one converted the object to JSON and back. That has somewhat changed with the addition of various features over time, though, so maybe we should indeed revisit this.

I would appreciate feedback from other implementors who have implemented this algorithm to see whether this is something that would quickly result in interoperable implementations, or whether this is something that would linger on with diverging implementations for some time.

In other words: If I change this, will Opera, Gecko, and WebKit change to match?
Comment 2 Jonas Sicking (Not reading bugmail) 2010-09-30 19:22:16 UTC
I don't think that this will cause any problems to Gecko. Structured cloning is used very rarely so far, and I strongly suspect that most of the time people use very simple objects that won't be affected by this change.

In fact, most of the time we use JSON behind the scenes, and so far no one has noticed the difference. This is changing though, so we will be using a custom structured-clone implementation soon.

The only requirement we have is that a structured-clone-able object can be serialized and serialized both quickly and with little overhead. This is needed for example in IndexedDB where we need to serialize the object to be able to store it in the database for later retrieval. Similarly we need to serialize and parse the object when passing data to workers.
Comment 3 Jonas Sicking (Not reading bugmail) 2010-09-30 21:46:40 UTC
I should also say that we're currently in the middle of rewriting our structured clone implementation. So any feedback on what the algorithm is going to be very soon would greatly helpful.
Comment 4 Anne 2010-10-01 08:15:19 UTC
This would be no problem for us. I am told we take extra steps to not implement this at the moment.
Comment 5 Ian 'Hixie' Hickson 2010-10-06 22:41:15 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: I made the algorithm support cycles and repeated objects in graphs.
Comment 6 contributor 2010-10-06 22:41:39 UTC
Checked in as WHATWG revision r5587.
Check-in comment: Make the structured clone algorithm support cycles.
http://html5.org/tools/web-apps-tracker?from=5586&to=5587