-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crash in NSLayoutManager during autorelease dealloc #523
Fix crash in NSLayoutManager during autorelease dealloc #523
Conversation
…iew." This reverts commit 5a67ae0.
|
Libraries/Text/Text/RCTTextView.m
Outdated
// associated NSLayoutManager dealloc later in an autorelease pool. | ||
// Manually removing the layout managers from _textStorage prior to release | ||
// works around this issue in AppKit. | ||
NSArray<NSLayoutManager *> *managers = [_textStorage layoutManagers]; |
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.
Can we confirm this makes a copy so we don't crash on mutating a collection while iterating it? If not we should explicitly copy the result of [_textStorage layoutManagers]
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.
Its a good call to copy it. In practice there's only ever a single object in the array but that could change.
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.
Looks like we're hitting the brew bundle CI validation failure here too
Summary: In a prior diff we removed some code that fixed an occasional crash in RCTTextView. This diff brings back the code, adapted from microsoft#523. Test Plan: Open the Text section of RNTester several times and verify no crash: |Before|After| |{F612971452}|{F612971479}| Reviewers: skyle Reviewed By: skyle Subscribers: eliwhite Differential Revision: https://phabricator.intern.facebook.com/D28166631 Tasks: T78743077 Signature: 28166631:1620086528:d359ab6e0c3477f2e52784534b6763156b33b1e5
Summary: In a prior diff we removed some code that fixed an occasional crash in RCTTextView. This diff brings back the code, adapted from microsoft#523. Test Plan: Open the Text section of RNTester several times and verify no crash: |Before|After| |{F612971452}|{F612971479}| Reviewers: skyle Reviewed By: skyle Subscribers: eliwhite Differential Revision: https://phabricator.intern.facebook.com/D28166631 Tasks: T78743077 Signature: 28166631:1620086528:d359ab6e0c3477f2e52784534b6763156b33b1e5
Summary: In a prior diff we removed some code that fixed an occasional crash in RCTTextView. This diff brings back the code, adapted from microsoft#523. Test Plan: Open the Text section of RNTester several times and verify no crash: |Before|After| |{F612971452}|{F612971479}| Reviewers: skyle Reviewed By: skyle Subscribers: eliwhite Differential Revision: https://phabricator.intern.facebook.com/D28166631 Tasks: T78743077 Signature: 28166631:1620086528:d359ab6e0c3477f2e52784534b6763156b33b1e5
Please select one of the following
Summary
The RCTTextView has an NSTextStorage ivar. When these objects are released and dealloced in an autorelease pool, sometimes there can be an exception thrown in system code as
NSLayoutManager dealloc
calls its own_NSRemoveDirtyLayoutManager
method which fails on a call to-[NSConcretePointerArray removePointerAtIndex:]
.We used to hit this issue consistently when resizing a window that contained many runs of text. The workaround was to manually remove all layout managers from the
_textStorage
ivar just prior to replacing it with another NSTextStorage.Even with this fix, the
[RNTesterSnapshotTests testTextExample]
test would still occasionally crash with the same callstack, and now @ospfranco reported the crash in a dependent project. Doing the same operation of manually removing all the layout managers from the text storage in RCTTextView dealloc seems to fix the issue. #357Changelog
[fixed] [macOS] - Fix crash in NSLayoutManager during autorelease dealloc
Test Plan
Re-enabled the previously disabled
[RNTesterSnapshotTests testTextExample]
test. @ospfranco manually tested the change.Microsoft Reviewers: Open in CodeFlow