-
Notifications
You must be signed in to change notification settings - Fork 6k
Migrate Dart_WeakPersistentHandle uses and roll Dart #19843
Migrate Dart_WeakPersistentHandle uses and roll Dart #19843
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@dcharkes Could you split out the finalizable handle part into a different PR which we can land normally. That way we keep the manual roll addressing the breaking API change small. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this code but I gave it a look. Looks good, I just had a few questions.
So, this is adding no functionality, just a refactor? That's why we are fine just relying on the old tests? There is some new surface like DartWeakPersistentValue which could be tested FWIW.
1ae07ab
to
a4cf7cd
Compare
Updating DEPS to point to a dart-lang/sdk branch does not seem to work out of the box. I'll check later if I can make that work to turn the CQ here green. In the mean time: another build run on the DartCQ: https://ci.chromium.org/p/dart/builders/try/flutter-engine-linux-try/327? (All green.) Tests also locally succeeded on revisions:
|
a4cf7cd
to
a6c09b8
Compare
a6c09b8
to
61c9ac7
Compare
@chinmaygarde Could you please have a look at this PR? (See the updated PR description.) In particular:
|
Yes, correct. |
a8338b1
to
0638046
Compare
I updated the PR to use the DEPS file to point to the branch containing the Dart changes. (Note that the licenses check is failing because I based the Dart branch on master instead of the commit that was in the DEPS file before.) |
Sorry for the long delay. My understanding is that an engine unit test would be able to make calls against the tonic API. That is, I don't think the test for this PR needs to be encapsulated entirely within tonic. Maybe I'm misunderstanding something? @chinmaygarde can correct me if I'm mistaken. |
ffa089e
to
52d1d8f
Compare
07bbce3
to
0d7952a
Compare
This pull request is not suitable for automatic merging in its current state.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm w/ license file fix
Changes Dart_NewWeakPersistentHandle to no longer auto delete the weak persistent handle. Changes the signatures of WeakPersistentHandleFinalizers to no longer have access to the handle. Flutter PR: flutter/engine#19843 g3 presubmit: cl/318028238 Issue: #42312 TEST=runtime/vm/dart_api_impl_test.cc Change-Id: I3f77db9954d9486759f903b78c03a494f73c68ba Cq-Include-Trybots:dart/try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151525 Commit-Queue: Daco Harkes <[email protected]> Reviewed-by: Ryan Macnak <[email protected]> Reviewed-by: Martin Kustermann <[email protected]>
0d7952a
to
1628bbd
Compare
1628bbd
to
a70f5ee
Compare
Requested changes with DEPS & licences addressed, merging. |
* c597333 Roll Skia from f548a028ce70 to c21902c0d3cc (46 revisions) (flutter/engine#22224) * 37d766c Fix includes to start with shell (flutter/engine#22227) * 1ad6765 [web] Fixes canvas pixelation and overallocation due to transforms. (flutter/engine#22160) * 9f9fc1f Roll Skia from c21902c0d3cc to 9615bcf71f2a (1 revision) (flutter/engine#22226) * 0faa72e Roll Dart SDK from fed66f60a3bc to 25ef5dc559cf (1 revision) (flutter/engine#22225) * 172a393 Report image diff status for iOS scenario golden tests (flutter/engine#22230) * fddabca updating integration tests version. (flutter/engine#22235) * a36bcdc Roll Fuchsia Mac SDK from mhak7e_o6... to 8SkbMXJJ9... (flutter/engine#22231) * 6a331d3 Roll Skia from 9615bcf71f2a to d5e6368fffd0 (8 revisions) (flutter/engine#22234) * 9b34207 Fixing semantics borders on mobile web (flutter/engine#21856) * 4e9459e Refactored the FlutterEngine to make it easier to implement spawn functionality (flutter/engine#21890) * fa77e68 disable AppLifecycleTests (flutter/engine#22236) * 153775b update golden (flutter/engine#22247) * 50dbe85 [web] fix hot restart type error (flutter/engine#22248) * c8cf09a Roll Skia from d5e6368fffd0 to 7585a65ac709 (7 revisions) (flutter/engine#22237) * 68e2e46 Roll Fuchsia Mac SDK from 8SkbMXJJ9... to Pz4ZHZrUp... (flutter/engine#22246) * d3182bc Roll Dart SDK from 25ef5dc559cf to 5acb5fcf84cb (4 revisions) (flutter/engine#22243) * 9b4bb20 makes android semanticsnode to ignore hittest if it is not focusable (flutter/engine#22205) * 3c7a54e Roll Fuchsia Linux SDK from sNx8qabBn... to QqGvMWaYk... (flutter/engine#22244) * eea98b2 Roll Skia from 7585a65ac709 to dffd20efe95c (14 revisions) (flutter/engine#22250) * 46e3bba Defer Windows arrow key and delete handling (flutter/engine#22207) * 14437d6 fix _getArrayBuffer signature (flutter/engine#22251) * 8defec6 Fix nullability issue with Image.network (flutter/engine#22252) * 67d55ed Roll Dart SDK from 5acb5fcf84cb to a9d583383410 (4 revisions) (flutter/engine#22255) * 7c8f57c Report error when instantiating CanvasKit network image (flutter/engine#22159) * 9945db3 Remove the metrics task from cirrus. (flutter/engine#22240) * bd19181 Add braces on if statements to match linter style (flutter/engine#22130) * e9c62e7 do not print in _computePixelDensity (flutter/engine#22257) * 2617101 Roll Dart SDK from a9d583383410 to d2577410a501 (1 revision) (flutter/engine#22258) * 3d194fa Switch macOS embedding to proc table embedder API (flutter/engine#21811) * 31b6f0b Roll Fuchsia Mac SDK from Pz4ZHZrUp... to 6yEx5GNGG... (flutter/engine#22262) * 78a0181 Roll Fuchsia Linux SDK from QqGvMWaYk... to oLF1FW-gC... (flutter/engine#22264) * ccdb681 WeakPersistentHandle migration (flutter/engine#19843) * ce0a30c Roll Dart SDK from 52783837369d to b43baaaa477d (723 revisions) (flutter/engine#22265) * 59b01e0 [web] Fix repaint logic for cullrect,transform changes (flutter/engine#22273)
and roll Dart to 5278383.
…that cross thread-boundaries. In flutter#19843, a regression was introduced where an image descriptor object that has a Dart peer could be collected on a concurrent task runner thread. Collection of such object needs to enter isolate scope which might still be active on the UI thread. [A comment in the original commit explicitly mentions][1] this and attempts to achieve the collection of the Dart wrappable on the UI task runner. However, the author missed that the object was present in the captures of a copyable closure. These captures may be released on any of the participating threads. To avoid the the indeterminism of the smart pointer being dropped on the concurrent task runner thread, this patch resorts to manually reference counting the descriptor. Fixes flutter/flutter#72144 [1]: https://github.com/flutter/engine/pull/19843/files#diff-a3034d4a06133381b6b636d841ec98cb7cfce640f316dda9e71eda4d9e7872f6R227
Description
The PR is migrating the users of
Dart_WeakPersistentHandle
because the semantics of that is changing to be non-auto-deleting to address races between the GC and API use. This rolls Dart to dart-lang/sdk@5278383.Most notably, this PR migrates
DartWrappable
to use the non-auto-deleting WeakPersistentHandles.DartWeakPersistentValue
to manageWeakPersistentHandles
, analogous to howDartPersistentValue
managesPersistentHandles
.DartWrappable
to useDartWeakPersistentValue
.DartWrappable
destructors can still be called on isolate shutdown, this PR addsDartState::is_shutting_down_
to cover this case.DartWrappable
destructors can no longer be called on arbitrary threads, becauseDart_DeleteWeakPersistentHandle
now has to be invoked manually and this must happen on the Dart mutator thread.src/flutter/lib/ui/painting/image_decoder.cc
).Related Issues
dart-lang/sdk#42312
Tests
I did not write new tests but ran the existing tests on HHH infrastructure. https://dart-review.googlesource.com/c/sdk/+/151525/27
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
https://dart-review.googlesource.com/c/sdk/+/151525 will break the Flutter build. This PR needs to be done with a Dart roll incorporating that CL.
Did any tests fail when you ran them? Please read handling breaking changes.