)]}'
{
  "commit": "cc241fa150e56a693848fc5269f1c0b149b218bb",
  "tree": "be71b39abef9f3cb7a50d2143c3eb73b3c697adb",
  "parents": [
    "a0f955f31caf8785b5cbd40b83fea7640e18c46e"
  ],
  "author": {
    "name": "Yegor",
    "email": "yjbanov@google.com",
    "time": "Wed Apr 05 11:08:00 2023 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Wed Apr 05 11:08:00 2023 -0700"
  },
  "message": "[web] fix SkFinalizationRegistry for dart2js (attempt 4) (#40938)\n\n(this is attempt 4; details below)\r\n\r\nRemove obsolete object caches and introduce a simpler way to manage\r\nnative objects:\r\n\r\n* Remove the unused `SynchronousSkiaObjectCache`.\r\n* Introduce new library `native_memory.dart` that\u0027s smaller and simpler\r\nthan `skia_object_cache.dart`.\r\n* Introduce two types of native object references:\r\n  * `UniqueRef` a reference with a unique Dart object owner.\r\n* `CountedRef` a ref-counted reference with multiple Dart object owners.\r\n* All native references use GC (via `FinalizationRegistry`) as a\r\nback-up.\r\n* The new library removes everything related to object resurrection that\r\nwas needed only in browsers that didn\u0027t support `FinalizationRegistry`.\r\nAll browsers support it now.\r\n* Remove the ad hoc `SkParagraph` cache that predates the introduction\r\nof `Paragraph.dispose`.\r\n* Rewrite `CkParagraph` in terms of `UniqueRef`.\r\n* Rewrite `CkImage` in terms of `CountedRef`; delete `SkiaObjectBox`.\r\n\r\nThis PR does not migrate all objects from the old\r\n`skia_object_cache.dart` to `native_memory.dart`. That would be too big\r\nof a change. The migration can be done in multiple smaller PRs.\r\n\r\nThis also removes a few unnecessary relayouts observed in\r\nhttps://github.com/flutter/flutter/issues/120921, but not all of them\r\n(more details in\r\nhttps://github.com/flutter/flutter/issues/120921#issuecomment-1481958762)\r\n\r\n## About attempt 4\r\n\r\nMore info about the revert of attempt 3 in\r\nhttps://github.com/flutter/engine/pull/40937.\r\n\r\nIn this attempt I check that the browser supports `FinalizationRegistry`\r\nbefore registering the object. This will allow the code to run in older\r\nbrowsers, but there will be no protection from memory leaks when the app\r\nfails to dispose of the respective objects.\r\n\r\n## Benchmarks\r\n\r\nNow that this landed in flutter/flutter I have some benchmark numbers\r\nfrom the devicelab. The `text_out_of_picture_bounds` benchmark dropped\r\nby 3-4x (lower is better):\r\n\r\n\u003cimg width\u003d\"358\" alt\u003d\"Screenshot 2023-04-04 at 6 13 06 PM\"\r\nsrc\u003d\"https://user-images.githubusercontent.com/211513/229956170-a5399ed3-c779-4af0-babb-ea40440f96ff.png\"\u003e\r\n\r\nThe repro provided in https://github.com/flutter/flutter/issues/123204\r\ndropped from 110ms/frame to 10ms/frame.",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "e5011256a6f6abb9477fe7f6fe322c34e40ad320",
      "old_mode": 33188,
      "old_path": "ci/licenses_golden/licenses_flutter",
      "new_id": "bfa34e3874d743ebea8a2464a672c146c9435c46",
      "new_mode": 33188,
      "new_path": "ci/licenses_golden/licenses_flutter"
    },
    {
      "type": "modify",
      "old_id": "a82b9d9b82a0efbc741d32ccafa4e32a74d17f33",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine.dart",
      "new_id": "07e54ca03c12743b6192f675316aee2b2be73f68",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine.dart"
    },
    {
      "type": "modify",
      "old_id": "3d35df90b4c41c6b1e22dc95797bbfbc60d2e0c8",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/canvas.dart",
      "new_id": "9a5dd90426cc738585b37e92901771081392e192",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/canvas.dart"
    },
    {
      "type": "modify",
      "old_id": "884f38f24290ef8d824495cad34d93511cf80fe2",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart",
      "new_id": "faacd1dd886b8e4a43e4ad52c2637d28fedeb86a",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/canvaskit_api.dart"
    },
    {
      "type": "modify",
      "old_id": "e43157da5313826c774f4f487e8555277c62e85f",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/image.dart",
      "new_id": "3e167422d992a1a851ba4d7a113c5277340a387a",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/image.dart"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "a4f0648a913a5ceb5db99f64c53bdf98d1460a4a",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/native_memory.dart"
    },
    {
      "type": "modify",
      "old_id": "28511bbba7bc30620350cb5b38b8ad41ffa6de9e",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/picture.dart",
      "new_id": "936d5897ba9ecb96a5b2fac8e1e656193afcc231",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/picture.dart"
    },
    {
      "type": "modify",
      "old_id": "21debea93cfb903c45cf97224608406b0832a5c1",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart",
      "new_id": "677397b9530822ff37eab4bdac8e209ec0648d56",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/skia_object_cache.dart"
    },
    {
      "type": "modify",
      "old_id": "2b4ab31d537280e43a1fbbfd40012367f14eae73",
      "old_mode": 33188,
      "old_path": "lib/web_ui/lib/src/engine/canvaskit/text.dart",
      "new_id": "ed14a91689099de84b74019faca2b57ba20e0e86",
      "new_mode": 33188,
      "new_path": "lib/web_ui/lib/src/engine/canvaskit/text.dart"
    },
    {
      "type": "modify",
      "old_id": "6bdd2b301d54d6cf9f23d338b49ae47ac482d2f3",
      "old_mode": 33188,
      "old_path": "lib/web_ui/test/canvaskit/canvaskit_api_test.dart",
      "new_id": "d2140d9f94618559770dcf693725bcb8ec7de105",
      "new_mode": 33188,
      "new_path": "lib/web_ui/test/canvaskit/canvaskit_api_test.dart"
    },
    {
      "type": "modify",
      "old_id": "3fae53fc9d9787e8c019b34d03e91fa4ff399283",
      "old_mode": 33188,
      "old_path": "lib/web_ui/test/canvaskit/image_golden_test.dart",
      "new_id": "ffc9507620f2e2c06e52bb3c8d2db20edb0a7aa6",
      "new_mode": 33188,
      "new_path": "lib/web_ui/test/canvaskit/image_golden_test.dart"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "42a99d284b65a85741151e0048c1281bd5412018",
      "new_mode": 33188,
      "new_path": "lib/web_ui/test/canvaskit/native_memory_test.dart"
    },
    {
      "type": "modify",
      "old_id": "9e7def11ca9bae136c98c158e6bbc297c14b2e71",
      "old_mode": 33188,
      "old_path": "lib/web_ui/test/canvaskit/skia_objects_cache_test.dart",
      "new_id": "14df75d7e709cf72f1fd2fcefae06d1f02c9177a",
      "new_mode": 33188,
      "new_path": "lib/web_ui/test/canvaskit/skia_objects_cache_test.dart"
    }
  ]
}
