Skip to content

Commit 8a1b084

Browse files
authored
Workaround crash during layout on macOS when a large number of flex (facebook#69)
layouts are being performed, such as during a window resize.
1 parent 7b57224 commit 8a1b084

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Libraries/Text/Text/RCTTextView.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ - (void)setTextStorage:(NSTextStorage *)textStorage
115115
contentFrame:(CGRect)contentFrame
116116
descendantViews:(NSArray<UIView *> *)descendantViews
117117
{
118+
#if TARGET_OS_OSX // [TODO(macOS ISS#2323203)
119+
// On macOS when a large number of flex layouts are being performed, such
120+
// as when a window is being resized, AppKit can throw an uncaught exception
121+
// (-[NSConcretePointerArray pointerAtIndex:]: attempt to access pointer at index ...)
122+
// during the dealloc of NSLayoutManager. The _textStorage and its
123+
// associated NSLayoutManager dealloc later in an autorelease pool.
124+
// Manually removing the layout manager from _textStorage prior to release
125+
// works around this issue in AppKit.
126+
NSArray<NSLayoutManager *> *managers = [_textStorage layoutManagers];
127+
for (NSLayoutManager *manager in managers) {
128+
[_textStorage removeLayoutManager:manager];
129+
}
130+
#endif // ]TODO(macOS ISS#2323203)
131+
118132
_textStorage = textStorage;
119133
_contentFrame = contentFrame;
120134

0 commit comments

Comments
 (0)