mirror of
https://github.com/status-im/react-native.git
synced 2025-02-21 13:48:13 +00:00
RN: Workaround HorizontalMeasurementProvider Crash
Summary: Adds a workaround to `ReactTextView` for a crash that happens in `getOffsetForHorizontal`: https://issuetracker.google.com/issues/113348914 Reviewed By: mdvacca Differential Revision: D13548917 fbshipit-source-id: 1c346283cd036c88d60a4b10890ade46c7e80eca
This commit is contained in:
parent
79cc1468bc
commit
19d69f9c22
@ -9,6 +9,7 @@ rn_android_library(
|
||||
],
|
||||
deps = [
|
||||
YOGA_TARGET,
|
||||
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
|
||||
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
|
@ -17,6 +17,8 @@ import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.uimanager.ReactCompoundView;
|
||||
import com.facebook.react.uimanager.ViewDefaults;
|
||||
import com.facebook.react.views.view.ReactViewBackgroundManager;
|
||||
@ -96,7 +98,14 @@ public class ReactTextView extends TextView implements ReactCompoundView {
|
||||
// TODO(5966918): Consider extending touchable area for text spans by some DP constant
|
||||
if (text instanceof Spanned && x >= lineStartX && x <= lineEndX) {
|
||||
Spanned spannedText = (Spanned) text;
|
||||
int index = layout.getOffsetForHorizontal(line, x);
|
||||
int index = -1;
|
||||
try {
|
||||
index = layout.getOffsetForHorizontal(line, x);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// https://issuetracker.google.com/issues/113348914
|
||||
FLog.e(ReactConstants.TAG, "Crash in HorizontalMeasurementProvider: " + e.getMessage());
|
||||
return target;
|
||||
}
|
||||
|
||||
// We choose the most inner span (shortest) containing character at the given index
|
||||
// if no such span can be found we will send the textview's react id as a touch handler
|
||||
|
Loading…
x
Reference in New Issue
Block a user