Mitigation for DDC bug in Chrome 87

187 views
Skip to first unread message

Siggi Cherem

unread,
Sep 8, 2020, 12:21:40 PM9/8/20
to anno...@dartlang.org
Summary
If you develop Dart Web or Flutter Web applications, you may need to take action to prevent development issues with Chrome 87.

Chrome 87 made a change that trips the Dart Web development compiler (DDC), which is used by `webdev serve` and `flutter run -d chrome`. Chrome 87 just got released on their dev channel. Once it arrives on the Chrome stable channel, the problem will be more visible.

A fix landed on master and Dart 2.9.3, and will be part of the upcoming beta releases. These releases will be available before Chrome 87 is available in the stable channel, so most users will require no action. If you encounter the issue in the future, confirm that you are using an SDK with the fix. If you can't upgrade to 2.9.3 or a newer SDK, a mitigation is available below.

The problem
To support DOM APIs from Dart, DDC stores data as hidden symbols on the constructor of types declared in `dart:html`. Chrome removed the constructor for one type (`MemoryInfo`) and as a result broke a DDC invariant. The downstream effect in DDC was that dynamic calls on arbitrary objects started failing (see #43287 and #43193 for details). Apps compiled with dart2js running on the same page also broke.

What does the error look like?
If you use DDC without the dart web debugger service (dwds) client, you may see unexplained NoSuchMethodErrors on dynamic calls, such as:

dart_sdk.js:99588 EXCEPTION: NoSuchMethodError: 'currentIndex'
method not found
Receiver: Instance of 'CollectionChangeRecord'
When using the dwds client (a dart2js app), you may see errors on that client, such as:

NoSuchMethodError: method not found: 'get$digestsPath' (J.getInterceptor$x(...).get$digestsPath is not a function)
TypeError: J.getInterceptor$x(...).get$digestsPath is not a function
    at Object.get$digestsPath$x (http://127.0.0.1:8080/dwds/src/injected/client.js:3536:43)
    at http://127.0.0.1:8080/dwds/src/injected/client.js:22757:60
    at _wrapJsFunctionForAsync_closure.$protected (http://127.0.0.1:8080/dwds/src/injected/client.js:3834:15)

Mitigation
If you can't upgrade to the latest Dart SDK, you simply need a couple lines of JavaScript on your HTML page ahead of any code compiled by DDC:

<script>
if (typeof window.MemoryInfo == "undefined") {
  if (typeof window.performance.memory != "undefined") {
    window.MemoryInfo = function () {};
    window.MemoryInfo.prototype = window.performance.memory.__proto__;
  }
}
</script>


Reply all
Reply to author
Forward
0 new messages