-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Mobile: Upgrade to React Native 0.79 #12337
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
Draft
personalizedrefrigerator
wants to merge
17
commits into
laurent22:dev
Choose a base branch
from
personalizedrefrigerator:pr/mobile/rn-0.79-try-2
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b807614
Mobile: WIP upgrade to React Native 0.79
personalizedrefrigerator 0ea19cd
iOS: Fix notifications
personalizedrefrigerator c5a7b4c
WIP: Android RN upgrade
personalizedrefrigerator ebb82f7
Fix most tests
personalizedrefrigerator f2514a9
Fix ShareManager test
personalizedrefrigerator eeefd37
Fixing more tests
personalizedrefrigerator 42116d4
Fix Note screen tests
personalizedrefrigerator fe6d22d
Lock file
personalizedrefrigerator 914cb7f
Update gradle files
personalizedrefrigerator 10ebfe4
Merge remote-tracking branch 'upstream/dev' into pr/mobile/rn-0.79-try-2
personalizedrefrigerator 51ceb1f
Fix revision viewer tests
personalizedrefrigerator 2c40462
Fix revision viewer tests
personalizedrefrigerator 286c096
iOS: Wait for camera to have permission before attempting startup wor…
personalizedrefrigerator 1f4d05a
Only load the camera after permission has been granted
personalizedrefrigerator 8f382e6
Merge remote-tracking branch 'refs/remotes/origin/pr/mobile/rn-0.79-t…
personalizedrefrigerator a1fd594
Migrating RN 0.74 patch, trying to fix iOS screen rotation bug
personalizedrefrigerator 2edcc51
Merge remote-tracking branch 'refs/remotes/origin/pr/mobile/rn-0.79-t…
personalizedrefrigerator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
# This patch fixes two issues: | ||
# - Updates RCTDeviceInfo.m to match https://github.com/facebook/react-native/commit/0b8db7e5e814cfbf9974cc5b6ceb64e8006d8a3c. | ||
# This fixes an issue in which useWindowDimensions returns incorrect | ||
# values in landscape mode in iOS. | ||
# This should be fixed in React Native 0.80. See https://github.com/facebook/react-native/issues/51086. | ||
# - Updates NativeAnimatedModule.java to work around an Android 12-specific crash. | ||
diff --git a/React/CoreModules/RCTDeviceInfo.mm b/React/CoreModules/RCTDeviceInfo.mm | ||
index 6b4fcef852252e8d4ac2aceb12175fdfafb4def7..8ceab21e8653d429876d10e2d12ed1342780ad7d 100644 | ||
--- a/React/CoreModules/RCTDeviceInfo.mm | ||
+++ b/React/CoreModules/RCTDeviceInfo.mm | ||
@@ -14,9 +14,7 @@ | ||
#import <React/RCTEventDispatcherProtocol.h> | ||
#import <React/RCTInitializing.h> | ||
#import <React/RCTInvalidating.h> | ||
-#import <React/RCTKeyWindowValuesProxy.h> | ||
#import <React/RCTUtils.h> | ||
-#import <React/RCTWindowSafeAreaProxy.h> | ||
#import <atomic> | ||
|
||
#import "CoreModulesPlugins.h" | ||
@@ -31,8 +29,13 @@ using namespace facebook::react; | ||
NSDictionary *_currentInterfaceDimensions; | ||
BOOL _isFullscreen; | ||
std::atomic<BOOL> _invalidated; | ||
+ NSDictionary *_constants; | ||
+ | ||
+ __weak UIWindow *_applicationWindow; | ||
} | ||
|
||
+static NSString *const kFrameKeyPath = @"frame"; | ||
+ | ||
@synthesize moduleRegistry = _moduleRegistry; | ||
|
||
RCT_EXPORT_MODULE() | ||
@@ -40,14 +43,26 @@ RCT_EXPORT_MODULE() | ||
- (instancetype)init | ||
{ | ||
if (self = [super init]) { | ||
- [[RCTKeyWindowValuesProxy sharedInstance] startObservingWindowSizeIfNecessary]; | ||
+ _applicationWindow = RCTKeyWindow(); | ||
+ [_applicationWindow addObserver:self forKeyPath:kFrameKeyPath options:NSKeyValueObservingOptionNew context:nil]; | ||
} | ||
return self; | ||
} | ||
|
||
+- (void)observeValueForKeyPath:(NSString *)keyPath | ||
+ ofObject:(id)object | ||
+ change:(NSDictionary *)change | ||
+ context:(void *)context | ||
+{ | ||
+ if ([keyPath isEqualToString:kFrameKeyPath]) { | ||
+ [self interfaceFrameDidChange]; | ||
+ [[NSNotificationCenter defaultCenter] postNotificationName:RCTWindowFrameDidChangeNotification object:self]; | ||
+ } | ||
+} | ||
+ | ||
+ (BOOL)requiresMainQueueSetup | ||
{ | ||
- return NO; | ||
+ return YES; | ||
} | ||
|
||
- (dispatch_queue_t)methodQueue | ||
@@ -81,7 +96,7 @@ RCT_EXPORT_MODULE() | ||
|
||
#if TARGET_OS_IOS | ||
|
||
- _currentInterfaceOrientation = [RCTKeyWindowValuesProxy sharedInstance].currentInterfaceOrientation; | ||
+ _currentInterfaceOrientation = RCTKeyWindow().windowScene.interfaceOrientation; | ||
|
||
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(interfaceFrameDidChange) | ||
@@ -98,6 +113,15 @@ RCT_EXPORT_MODULE() | ||
selector:@selector(invalidate) | ||
name:RCTBridgeWillInvalidateModulesNotification | ||
object:nil]; | ||
+ | ||
+ _constants = @{ | ||
+ @"Dimensions" : [self _exportedDimensions], | ||
+ // Note: | ||
+ // This prop is deprecated and will be removed in a future release. | ||
+ // Please use this only for a quick and temporary solution. | ||
+ // Use <SafeAreaView> instead. | ||
+ @"isIPhoneX_deprecated" : @(RCTIsIPhoneNotched()), | ||
+ }; | ||
} | ||
|
||
- (void)invalidate | ||
@@ -120,6 +144,8 @@ RCT_EXPORT_MODULE() | ||
|
||
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil]; | ||
|
||
+ [_applicationWindow removeObserver:self forKeyPath:kFrameKeyPath]; | ||
+ | ||
#if TARGET_OS_IOS | ||
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil]; | ||
#endif | ||
@@ -132,8 +158,13 @@ static BOOL RCTIsIPhoneNotched() | ||
|
||
#if TARGET_OS_IOS | ||
dispatch_once(&onceToken, ^{ | ||
+ RCTAssertMainQueue(); | ||
+ | ||
// 20pt is the top safeArea value in non-notched devices | ||
- isIPhoneNotched = [RCTWindowSafeAreaProxy sharedInstance].currentSafeAreaInsets.top > 20; | ||
+ UIWindow *keyWindow = RCTKeyWindow(); | ||
+ if (keyWindow) { | ||
+ isIPhoneNotched = keyWindow.safeAreaInsets.top > 20; | ||
+ } | ||
}); | ||
#endif | ||
|
||
@@ -142,11 +173,13 @@ static BOOL RCTIsIPhoneNotched() | ||
|
||
static NSDictionary *RCTExportedDimensions(CGFloat fontScale) | ||
{ | ||
+ RCTAssertMainQueue(); | ||
UIScreen *mainScreen = UIScreen.mainScreen; | ||
CGSize screenSize = mainScreen.bounds.size; | ||
+ UIView *mainWindow = RCTKeyWindow(); | ||
|
||
// We fallback to screen size if a key window is not found. | ||
- CGSize windowSize = [RCTKeyWindowValuesProxy sharedInstance].windowSize; | ||
+ CGSize windowSize = mainWindow ? mainWindow.bounds.size : screenSize; | ||
|
||
NSDictionary<NSString *, NSNumber *> *dimsWindow = @{ | ||
@"width" : @(windowSize.width), | ||
@@ -170,7 +203,10 @@ static NSDictionary *RCTExportedDimensions(CGFloat fontScale) | ||
RCTAssert(_moduleRegistry, @"Failed to get exported dimensions: RCTModuleRegistry is nil"); | ||
RCTAccessibilityManager *accessibilityManager = | ||
(RCTAccessibilityManager *)[_moduleRegistry moduleForName:"AccessibilityManager"]; | ||
- RCTAssert(accessibilityManager, @"Failed to get exported dimensions: AccessibilityManager is nil"); | ||
+ // TOOD(T225745315): For some reason, accessibilityManager is nil in some cases. | ||
+ // We default the fontScale to 1.0 in this case. This should be okay: if we assume | ||
+ // that accessibilityManager will eventually become available, js will eventually | ||
+ // be updated with the correct fontScale. | ||
CGFloat fontScale = accessibilityManager ? accessibilityManager.multiplier : 1.0; | ||
return RCTExportedDimensions(fontScale); | ||
} | ||
@@ -182,14 +218,7 @@ static NSDictionary *RCTExportedDimensions(CGFloat fontScale) | ||
|
||
- (NSDictionary<NSString *, id> *)getConstants | ||
{ | ||
- return @{ | ||
- @"Dimensions" : [self _exportedDimensions], | ||
- // Note: | ||
- // This prop is deprecated and will be removed in a future release. | ||
- // Please use this only for a quick and temporary solution. | ||
- // Use <SafeAreaView> instead. | ||
- @"isIPhoneX_deprecated" : @(RCTIsIPhoneNotched()), | ||
- }; | ||
+ return _constants; | ||
} | ||
|
||
- (void)didReceiveNewContentSizeMultiplier | ||
@@ -209,10 +238,11 @@ static NSDictionary *RCTExportedDimensions(CGFloat fontScale) | ||
- (void)interfaceOrientationDidChange | ||
{ | ||
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST | ||
- UIWindow *keyWindow = RCTKeyWindow(); | ||
- UIInterfaceOrientation nextOrientation = keyWindow.windowScene.interfaceOrientation; | ||
+ UIApplication *application = RCTSharedApplication(); | ||
+ UIInterfaceOrientation nextOrientation = RCTKeyWindow().windowScene.interfaceOrientation; | ||
|
||
- BOOL isRunningInFullScreen = CGRectEqualToRect(keyWindow.frame, keyWindow.screen.bounds); | ||
+ BOOL isRunningInFullScreen = | ||
+ CGRectEqualToRect(application.delegate.window.frame, application.delegate.window.screen.bounds); | ||
// We are catching here two situations for multitasking view: | ||
// a) The app is in Split View and the container gets resized -> !isRunningInFullScreen | ||
// b) The app changes to/from fullscreen example: App runs in slide over mode and goes into fullscreen-> | ||
@@ -276,3 +306,4 @@ Class RCTDeviceInfoCls(void) | ||
{ | ||
return RCTDeviceInfo.class; | ||
} | ||
+ | ||
diff --git a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java | ||
index cf14e51cf5f561b84f1b6ace8410fc77d626758e..abc8c64adf26fbf73429aee7fd4f76877e98849a 100644 | ||
--- a/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java | ||
+++ b/ReactAndroid/src/main/java/com/facebook/react/animated/NativeAnimatedModule.java | ||
@@ -42,6 +42,7 @@ import java.util.List; | ||
import java.util.Queue; | ||
import java.util.Set; | ||
import java.util.concurrent.ConcurrentLinkedQueue; | ||
+import java.util.concurrent.LinkedBlockingQueue; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
/** | ||
@@ -155,8 +156,15 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec | ||
} | ||
|
||
private class ConcurrentOperationQueue { | ||
- private final Queue<UIThreadOperation> mQueue = new ConcurrentLinkedQueue<>(); | ||
- @Nullable private UIThreadOperation mPeekedOperation = null; | ||
+ // Patch: Use LinkedBlockingQueue instead of ConcurrentLinkedQueue. | ||
+ // In some versions of Android, ConcurrentLinkedQueue is known to drop | ||
+ // items, causing crashing. See https://github.com/laurent22/joplin/issues/8425 | ||
+ private final Queue<UIThreadOperation> mQueue = ( | ||
+ // The issue exists for Android 12, which corresponds to API levels 31 and 32. | ||
+ Build.VERSION.SDK_INT == 31 || Build.VERSION.SDK_INT == 32 | ||
+ ) ? new LinkedBlockingQueue<>() : new ConcurrentLinkedQueue<>(); | ||
+ | ||
+ @Nullable private UIThreadOperation mPeekedOperation = null; | ||
|
||
@AnyThread | ||
boolean isEmpty() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,12 +104,12 @@ | |
"nanoid": "patch:nanoid@npm%3A3.3.7#./.yarn/patches/nanoid-npm-3.3.7-98824ba130.patch", | ||
"pdfjs-dist": "patch:pdfjs-dist@npm%3A3.11.174#./.yarn/patches/pdfjs-dist-npm-3.11.174-67f2fee6d6.patch", | ||
"chokidar@^2.0.0": "3.5.3", | ||
"[email protected]": "patch:react-native@npm%3A0.74.1#./.yarn/patches/react-native-npm-0.74.1-754c02ae9e.patch", | ||
"[email protected]": "patch:rn-fetch-blob@npm%3A0.12.0#./.yarn/patches/rn-fetch-blob-npm-0.12.0-cf02e3c544.patch", | ||
"[email protected]": "patch:app-builder-lib@npm%3A26.0.0-alpha.7#./.yarn/patches/app-builder-lib-npm-26.0.0-alpha.7-e1b3dca119.patch", | ||
"[email protected]": "patch:app-builder-lib@npm%3A24.13.3#./.yarn/patches/app-builder-lib-npm-24.13.3-86a66c0bf3.patch", | ||
"[email protected]": "patch:react-native-sqlite-storage@npm%3A6.0.1#./.yarn/patches/react-native-sqlite-storage-npm-6.0.1-8369d747bd.patch", | ||
"[email protected]": "patch:react-native-paper@npm%3A5.13.1#./.yarn/patches/react-native-paper-npm-5.13.1-f153e542e2.patch", | ||
"[email protected]": "patch:react-native-popup-menu@npm%3A0.17.0#./.yarn/patches/react-native-popup-menu-npm-0.17.0-8b745d88dd.patch" | ||
"[email protected]": "patch:react-native-popup-menu@npm%3A0.17.0#./.yarn/patches/react-native-popup-menu-npm-0.17.0-8b745d88dd.patch", | ||
"[email protected]": "patch:react-native@npm%3A0.79.2#./.yarn/patches/react-native-npm-0.79.2-9db13eddfe.patch" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/app-mobile/android/gradle/wrapper/gradle-wrapper.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,42 @@ | ||
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") } | ||
plugins { id("com.facebook.react.settings") } | ||
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() } | ||
pluginManagement { | ||
def reactNativeGradlePlugin = new File( | ||
providers.exec { | ||
workingDir(rootDir) | ||
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })") | ||
}.standardOutput.asText.get().trim() | ||
).getParentFile().absolutePath | ||
includeBuild(reactNativeGradlePlugin) | ||
|
||
def expoPluginsPath = new File( | ||
providers.exec { | ||
workingDir(rootDir) | ||
commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })") | ||
}.standardOutput.asText.get().trim(), | ||
"../android/expo-gradle-plugin" | ||
).absolutePath | ||
includeBuild(expoPluginsPath) | ||
} | ||
|
||
plugins { | ||
id("com.facebook.react.settings") | ||
id("expo-autolinking-settings") | ||
} | ||
|
||
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex -> | ||
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') { | ||
ex.autolinkLibrariesFromCommand() | ||
} else { | ||
ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand) | ||
} | ||
} | ||
expoAutolinking.useExpoModules() | ||
|
||
rootProject.name = 'Joplin' | ||
|
||
expoAutolinking.useExpoVersionCatalog() | ||
|
||
include ':react-native-vector-icons' | ||
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') | ||
|
||
include ':app' | ||
includeBuild('../node_modules/@react-native/gradle-plugin') | ||
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle") | ||
useExpoModules() | ||
includeBuild(expoAutolinking.reactNativeGradlePlugin) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
@testing-library/react-native
version removed *AccessibilityState queries.