Skip to content

Commit

Permalink
[spec] Normative: Prohibit IndexedDB serialization of Modules
Browse files Browse the repository at this point in the history
Based on discussions in the WebAssembly CG, it sounds like IndexedDB
serialization of WebAssembly Modules has the following problems:
- On some engines, it's impractical to serialize more than just the
  binary module data
- On some engines, upgrading from one version to another would cause
  the serialized module to be invalidated, with complicated implementation
  logic and a loss of reliability
- Some engines plan to just return an error for IndexedDB module
  serialization as a design decision

The purpose of IndexedDB Module serialization is for reliable performance,
and these items provide risks to that. This patch proposes that, initially,
IndexedDB serialization would not be provided for WebAssembly modules.
  • Loading branch information
littledan committed Jun 24, 2018
1 parent 1606c8e commit ab29f51
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions document/web-api/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,12 @@ Web user agents must augment the {{Module}} interface with the <code>[<a extende

The [=serialization steps=], given |value|, |serialized|, and |forStorage|, are:

1. If |forStorage| is true and the [=relevant settings object=]
of |value| is not [=contextually secure=], throw a
1. If |forStorage| is true, throw a
"<a exception>DataCloneError</a>" {{DOMException}}

1. Set |serialized|.\[[Bytes]] to the [=sub-serialization=] of |value|.\[[Bytes]].

1. If |forStorage| is *false*, set |serialized|.\[[AgentCluster]] to the
1. Set |serialized|.\[[AgentCluster]] to the
[=current Realm=]'s corresponding [=agent cluster=].

The [=deserialization steps=], given |serialized| and |value|, are:
Expand All @@ -156,8 +155,7 @@ The [=deserialization steps=], given |serialized| and |value|, are:

1. Set |value|.\[[Bytes]] to |bytes|.

1. If |serialized| has an \[[AgentCluster]] field, and if |targetRealm|'s
corresponding [=agent cluster=] is not
1. If |targetRealm|'s corresponding [=agent cluster=] is not
|serialized|.\[[AgentCluster]], then throw a
"<a exception>DataCloneError</a>" {{DOMException}}.

Expand All @@ -173,10 +171,6 @@ Given the above engine optimizations, structured serialization provides develope
explicit control over both compiled-code caching and cross-window/worker code
sharing.

Note: The web platform does not permit cross-origin sharing of serialized Modules: in the
case of |forStorage| being true, IndexedDB separates storage per origin; in the case of
|forStorage| being false, agent clusters in HTML do not span multiple origins.

<h2 id="conventions">Developer-Facing Display Conventions</h2>

<em>This section is non-normative.</em>
Expand Down

0 comments on commit ab29f51

Please sign in to comment.