-
Notifications
You must be signed in to change notification settings - Fork 6k
fixes reference retaining issue in flutter text input plugin #24768
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hi @gaaclarke I manage to write a mrc test to test the retaining count. I feel the test is quite fragile, but this is the only thing i can come up with. Can you take a look at this PR? |
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.
The fix looks good. I think the easiest way to test this would be to make an ARC test, then get a weak pointer to _activeView and assert that it does or does not get nil'd out to zero. Remember in ARC it will automatically set weak references to nil.
Something like this:
FlutterTextInputPlugin* plugin = [[FlutterTextInputPlugin alloc] init];
__weak UIView* activeView;
__weak UIView* oldActiveView;
@autoreleasepool {
UIView* newActiveView = [[UIView alloc] init];
activeView = newActiveView;
oldActiveView = plugin.activeView;
[plugin doSomethingThatReplacesTheActiveView:newActiveView];
}
// This assert proves that the plugin retained the newActiveView.
XCTAssertNotNil(activeView);
// This assert proves we released the old active view.
XCTAssertNil(oldActiveView);|
@gaaclarke ahhhh nice! thanks for the suggestion, it does capture the failure prior to this change. this is ready for review |
| }]; | ||
| XCTAssertNotNil(activeView); | ||
| } | ||
| // This assert proves the myInputPlugin.textInputView is not gc'd. |
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.
nit: s/gc'd/deallocated
* b2d02f7 Roll Fuchsia Linux SDK from GsRYVri0-... to aRqEDMjwC... (flutter/engine#24990) * 3a1a3e6 Roll Skia from 7854da39b3c1 to 4fb13e026b6b (20 revisions) (flutter/engine#24993) * e3a84f9 Fixed issue where the gpu disable syncswitch was being overridden after init. (flutter/engine#24958) * aa83691 fix selectable text selections are not announced in voice over (flutter/engine#24933) * 04b0451 fixes reference retaining issue in flutter text input plugin (flutter/engine#24768) * 1ea7dc6 Set automatic simulator rotation in scenario test (flutter/engine#24985) * 38977a5 Implement AXPlatformNodeBase::GetInstanceCountForTesting (flutter/engine#24999) * a25b0de Roll Fuchsia Mac SDK from xOxFrRRO6... to pmsuWkRQA... (flutter/engine#24997) * 3270c87 Roll Skia from 4fb13e026b6b to 1aa25c3217b6 (25 revisions) (flutter/engine#25001) * 96d5104 [deferred components] Handle base module loading units (flutter/engine#24983) * 6a3d8c7 Roll Skia from 1aa25c3217b6 to ead52dc068d5 (1 revision) (flutter/engine#25005) * 0f52360 Hardware Keyboard: macOS (flutter/engine#23469)
The inputview is created without anyone retaining, it work prior to this pr because the inputview was never detached from the flutterview, so the flutter view retains one reference.
My previous commit b3a18f5 detaches the inputview when user hides it, this makes it to be gc'd. This causes _activeView hold an invalid pointer.
fixes flutter/flutter#77139
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.