Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move transform3D property from RCTView to RCTUIView #1936

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

amgleitman
Copy link
Member

Please select one of the following

  • I am removing an existing difference between facebook/react-native and microsoft/react-native-macos πŸ‘
  • I am cherry-picking a change from Facebook's react-native into microsoft/react-native-macos πŸ‘
  • I am making a fix / change for the macOS implementation of react-native
  • I am making a change required for Microsoft usage of react-native

Summary

We've received reports of the following red box in react-native-svg:

-[RNSVGSvgView setTransform3D:]: unrecognized selector sent to instance <address>

The reason for this is because of the following inheritance chain:

  • iOS: RNSVGSvgView (subclass of) RNSVGView (#defined as) UIView
  • macOS: RNSVGSvgView (subclass of) RNSVGView (subclass of) RCTUIView (subclass of) RCTPlatformView (#defined as) NSView

transform3D exists on UIView, but it doesn't exist on NSView, so we previously implemented it on RCTView, which is a separate subclass of RCTUIView. However, RCTView (like its counterpart in RNCore) is meant to augment the default OS-level view with RN-specific functionality, while RCTUIView (which is exclusive to react-native-macos) is meant to add UIView-like features that don't already exist on NSView.

By this logic, transform3D should really be at the RCTUIView level.

Other Notes

There are a couple of other cases in RNTester-macOS that have similar problems with their inheritance chains:

  • FlatList > Basic, which has a problem with -[RCTSwitch setTransform3D:]
    • iOS: RCTSwitch (subclass of) UISwitch (subclass of) UIControl (subclass of) UIView βœ…
    • macOS: RCTSwitch (subclass of) RCTUISwitch (subclass of) NSSwitch, doesn't pass through RCTUIView ❌
  • Accessibility, which has a problem with -[RCTTextView setOnKeyUp:]
    • iOS: RCTTextView (subclass of) UIView βœ…
    • macOS: RCTSwitch (subclass of) RCTUIView (subclass of) RCTPlatformView (#defined as) NSView, doesn't pass through RCTView ❌

These require further discussions about how different control views are inherited. These could presumably be fixed by wrapping said control views in a View of their own, but this is an awkward experience that ought to be avoidable. We should discuss these at a later time, but this fix on its own still has merit.

Changelog

[MACOS] [FIXED] - transform3D is now a property of RCTUIView

Test Plan

a524840 fixes the issue on the Accessibility page, but that change is arguably too aggressive because of the differences between RCTView and RCTUIView. Nevertheless, this demonstrates that this solution is viable.

@amgleitman amgleitman requested a review from a team as a code owner September 15, 2023 21:34
Comment on lines +420 to +423
#if TARGET_OS_OSX // [macOS
// macOS Properties
@property (nonatomic, assign) CATransform3D transform3D;
#endif // macOS]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this already in a giant macOS block, so we don't need the extra ifdef?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. Will fix.

@@ -245,6 +245,7 @@ @implementation RCTUIView
self->_userInteractionEnabled = YES;
self->_enableFocusRing = YES;
self->_mouseDownCanMoveWindow = YES;
self->_transform3D = CATransform3DIdentity;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to read this somewhere in a updateLayer style method so we actually do the 3D transform?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants