Skip to content

Refactor to not modify view-backing layer properties which is documented as undefined behavior by Apple  #466

@tom-un

Description

@tom-un

react-native for iOS implements several features (z-order, rotation, shadows, and clipping) by modifying view-backing layer properties directly which is permitted on iOS. When react-native for iOS was ported to react-native-macos it uses the same code as iOS. However, Apple has documented that modifing certain layer props on a layer owned by an NSView is "undefined behavior" since macOS 10.13 (https://developer.apple.com/library/archive/releasenotes/AppKit/RN-AppKit/#10_13Layer-backed%20Views).

Although modifying these layer props work up to macOS 10.15, a future release could break these features. This issue tracks the work to refactor react-native-macos to not modify these layer props. The following table lists the props that should not be modified on a view.layer and annotates where we are currently making modifications:

Layer prop view.layer change
bounds
position
zPosition modified by setReactZIndex: in UIView+React.m
anchorPoint
anchorPointZ
transform modified in RCTUIManager and RCTViewManager
affineTransform modified in RCTUIKit by RCTUIView setTransform:
frame
hidden
geometryFlipped
masksToBounds modified by RCTView displayLayer:
opaque
compositingFilter
filters
shadowColor modified by RCTViewManager
shadowOpacity modified by RCTViewManager
shadowOffset modified by RCTViewManager
shadowRadius modified by RCTViewManager
shadowPath modified by RCTUpdateShadowPathForView in RCTView.m
layoutManager

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions