Skip to content

Commit

Permalink
Disable weak event emitter in AttributedString for Apple Silicon Mac …
Browse files Browse the repository at this point in the history
…running iOS build app (#48583)

Summary:
#48225 fixed the same problem on Mac Catalyst build, but this crash also happen on a iOS build app running on Apple Silicon Mac.
The weak event emitter in AttributedString attributes is causing a serialization error when typing into a TextInput in a iOS build app running on Apple Silicon Mac.

## Changelog

[iOS][Fixed] - Workaround for a iOS build app running on Apple Silicon Mac(in Xcode Destination: "Mac(Designed for iPad)") TextInput crash due to serialization attempt of WeakEventEmitter

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #48583

Reviewed By: javache

Differential Revision: D68093083

Pulled By: cipolleschi

fbshipit-source-id: ac48be3305eb01ff2b62d63283b929e8ab6b250c
  • Loading branch information
iwater authored and facebook-github-bot committed Jan 16, 2025
1 parent 8a12672 commit 0511e2e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ - (void)updateEventEmitter:(const EventEmitter::Shared &)eventEmitter
NSMutableDictionary<NSAttributedStringKey, id> *defaultAttributes =
[_backedTextInputView.defaultTextAttributes mutableCopy];

#if !TARGET_OS_MACCATALYST
#if !TARGET_OS_MAC && !TARGET_OS_MACCATALYST
RCTWeakEventEmitterWrapper *eventEmitterWrapper = [RCTWeakEventEmitterWrapper new];
eventEmitterWrapper.eventEmitter = _eventEmitter;
defaultAttributes[RCTAttributedStringEventEmitterKey] = eventEmitterWrapper;
Expand Down Expand Up @@ -266,7 +266,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
if (newTextInputProps.textAttributes != oldTextInputProps.textAttributes) {
NSMutableDictionary<NSAttributedStringKey, id> *defaultAttributes =
RCTNSTextAttributesFromTextAttributes(newTextInputProps.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
#if !TARGET_OS_MACCATALYST
#if !TARGET_OS_MAC && !TARGET_OS_MACCATALYST
defaultAttributes[RCTAttributedStringEventEmitterKey] =
_backedTextInputView.defaultTextAttributes[RCTAttributedStringEventEmitterKey];
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText)
{
auto nsAttributedStringFragment = RCTNSAttributedStringFragmentFromFragment(fragment, placeholderImage);

#if !TARGET_OS_MACCATALYST
#if !TARGET_OS_MAC && !TARGET_OS_MACCATALYST
if (fragment.parentShadowView.componentHandle) {
RCTWeakEventEmitterWrapper *eventEmitterWrapper = [RCTWeakEventEmitterWrapper new];
eventEmitterWrapper.eventEmitter = fragment.parentShadowView.eventEmitter;
Expand Down

0 comments on commit 0511e2e

Please sign in to comment.