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

Fix Xcode warnings in React-Core pod #29622

Closed
wants to merge 7 commits into from

Conversation

jdeff
Copy link
Contributor

@jdeff jdeff commented Aug 11, 2020

Summary

With the upgrade to React Native 0.63, we started running into nullability warnings that were breaking our build. This PR fixes those nullability warnings as well as a few other warnings in React-Core.

Changelog

[iOS] [Fixed] - Fix xcodebuild warnings in React-Core

Test Plan

  • Nullability annotations should only affect compilation, but even though RNTester compiles, I'm not fully convinced that this won't break projects downstream. It would be good to get another opinion on this.
  • The change in RCTAllocateRootViewTag is the only real logic change in this PR. We throw an exception if the root view tag is not in the correct format, so this change seems safe after some basic manual testing in RNTester.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 11, 2020
RNTester/Podfile.lock Outdated Show resolved Hide resolved
@react-native-bot react-native-bot added Bug Platform: iOS iOS applications. labels Aug 11, 2020
@analysis-bot
Copy link

analysis-bot commented Aug 11, 2020

Platform Engine Arch Size (bytes) Diff
ios - universal n/a --

Base commit: f8e5423

@safaiyeh
Copy link
Contributor

cc @alloy

@analysis-bot
Copy link

analysis-bot commented Aug 11, 2020

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 7,003,051 0
android hermes armeabi-v7a 6,666,643 0
android hermes x86 7,423,338 0
android hermes x86_64 7,314,249 0
android jsc arm64-v8a 9,162,901 0
android jsc armeabi-v7a 8,818,626 0
android jsc x86 9,011,283 0
android jsc x86_64 9,588,386 0

Base commit: f8e5423

Copy link
Contributor

@alloy alloy left a comment

Choose a reason for hiding this comment

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

Nice one, thanks 👍

No approval or request for changes just yet.

.gitignore Outdated
@@ -88,6 +88,7 @@ RNTester/build
/template/ios/Pods/
/template/ios/Podfile.lock
/RNTester/Gemfile.lock
/RNTester/vendor
Copy link
Contributor

Choose a reason for hiding this comment

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

What’s this about?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The vendor directory came for running bundle install --path vendor, which I did to avoid installing the gems as system gems. I can remove it from this PR. It would be nice to have some better instructions on how to set up the development environment for newbies.

RNTester/Podfile.lock Outdated Show resolved Hide resolved
[self reloadWithReason:@"Command"];
#pragma clang diagnostic pop
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if this is being tracked in an issue? Seeing as it will now go silent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for calling this out. I went ahead and took a stab at moving off these deprecated methods. Let me know if I should revert that and just file an issue instead.

@@ -100,7 +100,7 @@ + (instancetype)stackFrameWithLine:(NSString *)line
file:file
lineNumber:[lineNumber integerValue]
column:[column integerValue]
collapse:@NO];
collapse:@NO.integerValue];
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a smell. Can the collapse var be made a BOOL instead, at least internally to this class? If not, then at least it seems better to just pass 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Shouldn't be a huge change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it to BOOL.

@@ -1125,6 +1128,8 @@ - (void)reloadWithReason:(NSString *)reason
RCTTriggerReloadCommandListeners(reason);
}

#pragma clang diagnostic pop
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as before, this should be tracked in some way. Perhaps the alternative to an issue is to leave comments pointing to these call-sites from the deprecated implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since RCTCxxBridge inherits from RCTBridge, I went ahead and just removed these overrides, since RCTBridge now has the same implementation as this (minus the warn log).

@@ -8,6 +8,7 @@
#import "RCTUIManagerUtils.h"

#import <libkern/OSAtomic.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this import go too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Fixed.

@@ -98,6 +99,6 @@ void RCTUnsafeExecuteOnUIManagerQueueSync(dispatch_block_t block)
NSNumber *RCTAllocateRootViewTag()
{
// Numbering of these tags goes from 1, 11, 21, 31, ..., 100501, ...
static int64_t rootViewTagCounter = -1;
return @(OSAtomicIncrement64(&rootViewTagCounter) * 10 + 1);
static _Atomic int64_t rootViewTagCounter = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

From the docs:

Atomically replaces the value pointed by obj with the result of addition of arg to the old value of obj, and returns the value obj held previously.

So that’s why this should initialise with 0 instead of -1, like previously was the case.

Do you know if there are tests that cover this API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know of any tests per se, but the RNTester app crashed immediately when this was initialized to -1.

[RCTProfilingBridge() reloadWithReason:@"Profiling controls"];
#pragma clang diagnostic pop
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor

@alloy alloy left a comment

Choose a reason for hiding this comment

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

Well, I guess some questions are actual request for changes 😄

@jdeff jdeff requested a review from alloy August 19, 2020 21:46
@jdeff
Copy link
Contributor Author

jdeff commented Aug 19, 2020

Thanks for the review @alloy. I think I've resolved all of the comments.

Copy link
Contributor

@alloy alloy left a comment

Choose a reason for hiding this comment

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

Great, thanks for your work!

/cc @TheSavior

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@appden has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by Jayme Deffenbaugh in cb719a1.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 9, 2020
@@ -36,6 +36,9 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDelay;
@property (nonatomic, assign) NSTimeInterval loadingViewFadeDuration;

- (instancetype)initWithSurface:(RCTSurface *)surface
sizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode NS_UNAVAILABLE;
Copy link
Contributor

Choose a reason for hiding this comment

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

@jdeff Sorry, I had to remove this one before merging because it caused issues with Facebook's internal builds.

Copy link
Contributor

Choose a reason for hiding this comment

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

@appden Can you share details about the build failure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants