Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.annotation.StringDef
import com.facebook.common.logging.FLog
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.CLIPPING_PROHIBITED_VIEW
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.RVG_ADD_CHILDREN_FOR_ACCESSIBILITY
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.RVG_IS_VIEW_CLIPPED
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.RVG_ON_VIEW_REMOVED
import com.facebook.react.bridge.ReactSoftExceptionLogger.Categories.SOFT_ASSERTIONS
Expand All @@ -21,6 +22,7 @@ import java.util.concurrent.CopyOnWriteArrayList
internal object ReactSoftExceptionLogger {
@Retention(AnnotationRetention.SOURCE)
@StringDef(
RVG_ADD_CHILDREN_FOR_ACCESSIBILITY,
RVG_IS_VIEW_CLIPPED,
RVG_ON_VIEW_REMOVED,
CLIPPING_PROHIBITED_VIEW,
Expand All @@ -31,6 +33,8 @@ internal object ReactSoftExceptionLogger {

/** Constants that listeners can utilize for custom category-based behavior. */
object Categories {
const val RVG_ADD_CHILDREN_FOR_ACCESSIBILITY: String =
"ReactViewGroup.addChildrenForAccessibility"
const val RVG_IS_VIEW_CLIPPED: String = "ReactViewGroup.isViewClipped"
const val RVG_ON_VIEW_REMOVED: String = "ReactViewGroup.onViewRemoved"
const val CLIPPING_PROHIBITED_VIEW: String = "ReactClippingProhibitedView"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,12 @@ public open class ReactViewGroup public constructor(context: Context?) :
} else if (axOrderParentOrderList != null) {
// view is a container so add its children normally
if (!isFocusable) {
super.addChildrenForAccessibility(outChildren)
safeAddChildrenForAccessibility(outChildren)
return

// If this view can coopt, turn the focusability off its children but add them to the tree
} else if (isFocusable && (contentDescription == null || contentDescription == "")) {
super.addChildrenForAccessibility(outChildren)
safeAddChildrenForAccessibility(outChildren)
for (i in 0..<childCount) {
ReactAxOrderHelper.disableFocusForSubtree(getChildAt(i), axOrderParentOrderList)
}
Expand All @@ -1012,7 +1012,23 @@ public open class ReactViewGroup public constructor(context: Context?) :
return
}
} else {
safeAddChildrenForAccessibility(outChildren)
}
}

private fun safeAddChildrenForAccessibility(outChildren: ArrayList<View>) {
try {
super.addChildrenForAccessibility(outChildren)
} catch (error: IllegalArgumentException) {
// Android 16 can race while building accessibility child lists during fast re-parenting.
if (error.message?.contains("descendant of this view") == true) {
logSoftException(
ReactSoftExceptionLogger.Categories.RVG_ADD_CHILDREN_FOR_ACCESSIBILITY,
error,
)
} else {
throw error
}
}
}

Expand Down
Loading