Fabric: Fixing a crash in RCTParagraphComponentView
Summary: We don't know why exactly it happens but (seemingly) sometime Paragraph component receives an empty State object. This causes a crash because of unchecked access to an instance variable. This diff introduces an assert in DEBUG mode and the check for prod. Why is this happens? Hard to say, probably `layout()` method (which updates `State`) is not being called on ShadowNode. Why? One explanation can be that Yoga skips some subtree during layout because it starts from "visibility: hidden" component. We need to investigate it more and figure out what exactly going on and what should we need to improve besides the check. That's why we have an assertion. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D20260512 fbshipit-source-id: 4772855f41c6694be2ed6c0a19da40332d2bb8db
This commit is contained in:
Родитель
c18cc76e58
Коммит
6530c90267
|
@ -80,7 +80,13 @@ using namespace facebook::react;
|
|||
return;
|
||||
}
|
||||
|
||||
SharedTextLayoutManager textLayoutManager = _state->getData().layoutManager;
|
||||
auto textLayoutManager = _state->getData().layoutManager;
|
||||
assert(textLayoutManager && "TextLayoutManager must not be `nullptr`.");
|
||||
|
||||
if (!textLayoutManager) {
|
||||
return;
|
||||
}
|
||||
|
||||
RCTTextLayoutManager *nativeTextLayoutManager =
|
||||
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
|
||||
|
||||
|
@ -113,16 +119,22 @@ using namespace facebook::react;
|
|||
return _eventEmitter;
|
||||
}
|
||||
|
||||
SharedTextLayoutManager textLayoutManager = _state->getData().layoutManager;
|
||||
auto textLayoutManager = _state->getData().layoutManager;
|
||||
|
||||
assert(textLayoutManager && "TextLayoutManager must not be `nullptr`.");
|
||||
|
||||
if (!textLayoutManager) {
|
||||
return _eventEmitter;
|
||||
}
|
||||
|
||||
RCTTextLayoutManager *nativeTextLayoutManager =
|
||||
(__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager();
|
||||
CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame());
|
||||
|
||||
SharedEventEmitter eventEmitter =
|
||||
[nativeTextLayoutManager getEventEmitterWithAttributeString:_state->getData().attributedString
|
||||
paragraphAttributes:_paragraphAttributes
|
||||
frame:frame
|
||||
atPoint:point];
|
||||
auto eventEmitter = [nativeTextLayoutManager getEventEmitterWithAttributeString:_state->getData().attributedString
|
||||
paragraphAttributes:_paragraphAttributes
|
||||
frame:frame
|
||||
atPoint:point];
|
||||
|
||||
if (!eventEmitter) {
|
||||
return _eventEmitter;
|
||||
|
|
Загрузка…
Ссылка в новой задаче