From 8631bbbc154b8d59ccfe3e7ba166eaaaacd6f644 Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Thu, 28 May 2020 14:38:47 -0700 Subject: [PATCH] [safe-area-context] Update to 3.0.2 (#8549) * [safe-area-context] Update to 3.0.2 * Update CHANGELOG, remove a couple of PRs from safe-area-context * Update CHANGELOG.md Co-authored-by: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com> Co-authored-by: Tomasz Sapeta <1714764+tsapeta@users.noreply.github.com> --- CHANGELOG.md | 2 +- .../api/safeareacontext/SafeAreaView.java | 16 +++++++++++++--- apps/bare-expo/package.json | 2 +- apps/native-component-list/package.json | 2 +- home/package.json | 2 +- packages/expo/bundledNativeModules.json | 2 +- packages/expo/package.json | 2 +- yarn.lock | 8 ++++---- 8 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f99d06e579adb..bab8a7f72e664 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ Package-specific changes not released in any SDK will be added here just before - Updated `react-native-screens` from `2.2.0` to `2.8.0`. ([#8434](https://github.com/expo/expo/pull/8424) by [@sjchmiela](https://github.com/sjchmiela)) - Updated `react-native-shared-element` from `0.5.6` to `0.7.0`. ([#8427](https://github.com/expo/expo/pull/8427) by [@IjzerenHein](https://github.com/IjzerenHein)) - Updated `react-native-reanimated` from `1.7.0` to `1.9.0`. ([#8424](https://github.com/expo/expo/pull/8424) by [@sjchmiela](https://github.com/sjchmiela)) -- Updated `react-native-safe-area-context` from `0.7.3` to `3.0.0`. ([#8459](https://github.com/expo/expo/pull/8459) by [@brentvatne](https://github.com/brentvatne) and [#8479](https://github.com/expo/expo/pull/8479) by [@tsapeta](https://github.com/tsapeta)) and [#8503](https://github.com/expo/expo/pull/8459) by [@brentvatne](https://github.com/brentvatne) and [#8544](https://github.com/expo/expo/pull/8544) by [@brentvatne](https://github.com/brentvatne). +- Updated `react-native-safe-area-context` from `0.7.3` to `3.0.0`. ([#8459](https://github.com/expo/expo/pull/8459), [#8479](https://github.com/expo/expo/pull/8479), [#8549](https://github.com/expo/expo/pull/8549) by [@brentvatne](https://github.com/brentvatne) and [@tsapeta](https://github.com/tsapeta)) - Updated `@react-native-community/datetimepicker` from `2.2.2` to `2.4.0`. ([#8476](https://github.com/expo/expo/pull/8476) by [@tsapeta](https://github.com/tsapeta)) - Updated `react-native-webview` from `8.1.1` to `9.4.0`. ([#8489](https://github.com/expo/expo/pull/8489) by [@tsapeta](https://github.com/tsapeta)) - Updated `react-native-svg` from `11.0.1` to `12.1.0`. ([#8491](https://github.com/expo/expo/pull/8491) by [@tsapeta](https://github.com/tsapeta)) diff --git a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/safeareacontext/SafeAreaView.java b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/safeareacontext/SafeAreaView.java index 8bf42b4dffe8d..421291fe98446 100644 --- a/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/safeareacontext/SafeAreaView.java +++ b/android/expoview/src/main/java/versioned/host/exp/exponent/modules/api/safeareacontext/SafeAreaView.java @@ -3,6 +3,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.content.ContextWrapper; +import android.util.Log; import android.view.View; import android.view.ViewParent; import android.view.ViewTreeObserver; @@ -55,14 +56,18 @@ private void updateInsets() { } } + // 5 seconds + private static final long MAX_WAIT_TIME_NANO = 5000000000L; + private void waitForReactLayout() { // Block the main thread until the native module thread is finished with // its current tasks. To do this we use the done boolean as a lock and enqueue // a task on the native modules thread. When the task runs we can unblock the // main thread. This should be safe as long as the native modules thread // does not block waiting on the main thread. - // TODO: Investigate perf impact. final AtomicBoolean done = new AtomicBoolean(false); + final long startTime = System.nanoTime(); + long waitTime = 0L; getReactContext(this).runOnNativeModulesQueueThread(new Runnable() { @Override public void run() { @@ -73,12 +78,17 @@ public void run() { } }); synchronized (done) { - while (!done.get()) { + while (!done.get() && waitTime < MAX_WAIT_TIME_NANO) { try { - done.wait(); + done.wait(MAX_WAIT_TIME_NANO / 1000000L); } catch (InterruptedException e) { e.printStackTrace(); } + waitTime = System.nanoTime() - startTime; + } + // Timed out waiting. + if (waitTime >= MAX_WAIT_TIME_NANO) { + Log.w("SafeAreaView", "Timed out waiting for layout."); } } } diff --git a/apps/bare-expo/package.json b/apps/bare-expo/package.json index 4ddc0e440ad98..e1f1c664d6d81 100644 --- a/apps/bare-expo/package.json +++ b/apps/bare-expo/package.json @@ -92,7 +92,7 @@ "react-native-appearance": "~0.3.3", "react-native-gesture-handler": "~1.6.0", "react-native-reanimated": "~1.9.0", - "react-native-safe-area-context": "3.0.0", + "react-native-safe-area-context": "3.0.2", "react-native-screens": "~2.8.0", "react-native-unimodules": "~0.10.0", "react-native-web": "^0.11.4", diff --git a/apps/native-component-list/package.json b/apps/native-component-list/package.json index bd315dcdb5b3f..ee3706e799fe4 100644 --- a/apps/native-component-list/package.json +++ b/apps/native-component-list/package.json @@ -92,7 +92,7 @@ "react-native-paper": "github:brentvatne/react-native-paper#@brent/fix-bottom-navigation-rn-57", "react-native-platform-touchable": "^1.1.1", "react-native-reanimated": "~1.9.0", - "react-native-safe-area-context": "3.0.0", + "react-native-safe-area-context": "3.0.2", "react-native-safe-area-view": "^0.14.8", "react-native-screens": "~2.8.0", "react-native-shared-element": "0.7.0", diff --git a/home/package.json b/home/package.json index 88f02223143ba..5a5d0988f7ae3 100644 --- a/home/package.json +++ b/home/package.json @@ -51,7 +51,7 @@ "react-native-gesture-handler": "~1.6.0", "react-native-infinite-scroll-view": "^0.4.5", "react-native-maps": "0.27.1", - "react-native-safe-area-context": "3.0.0", + "react-native-safe-area-context": "3.0.2", "react-navigation": "4.1.0-alpha.1", "react-navigation-material-bottom-tabs": "1.1.1", "react-navigation-stack": "^2.0.15", diff --git a/packages/expo/bundledNativeModules.json b/packages/expo/bundledNativeModules.json index 0e0745994f3a1..4086c40b7ee5f 100644 --- a/packages/expo/bundledNativeModules.json +++ b/packages/expo/bundledNativeModules.json @@ -79,7 +79,7 @@ "expo-in-app-purchases": "~8.2.0", "expo-branch": "~2.2.0", "react-native-appearance": "~0.3.3", - "react-native-safe-area-context": "3.0.0", + "react-native-safe-area-context": "3.0.2", "react-native-shared-element": "0.7.0", "expo-application": "~2.2.1", "expo-battery": "~2.2.0", diff --git a/packages/expo/package.json b/packages/expo/package.json index ce29c4d3be5d9..f86ec60e2ca20 100644 --- a/packages/expo/package.json +++ b/packages/expo/package.json @@ -75,7 +75,7 @@ "nullthrows": "^1.1.0", "pretty-format": "^23.6.0", "prop-types": "^15.6.0", - "react-native-safe-area-context": "3.0.0", + "react-native-safe-area-context": "3.0.2", "serialize-error": "^2.1.0", "unimodules-app-loader": "~1.1.0", "unimodules-barcode-scanner-interface": "~5.2.0", diff --git a/yarn.lock b/yarn.lock index a65154ac2a05c..15fc89b050d6b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13949,10 +13949,10 @@ react-native-reanimated@~1.9.0: dependencies: fbjs "^1.0.0" -react-native-safe-area-context@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.0.0.tgz#09a326aa2713b830cfe0451ed7649f5d9cf2aa65" - integrity sha512-98ZeGgtr2YxPJUzL5tgh7v3kcvnD5iPT+2RS5inn40dkPPPsBNXqcqkBiQyWIvfBCahQfwXH2PA2diX+AUz16A== +react-native-safe-area-context@3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.0.2.tgz#95dd7e56bc89bcc4f3f7bb5fada30c98420328b2" + integrity sha512-x3yVMsxwe9GyvIkv0Q5jy2CWYN7VO0/CJTFGG5kSiMo8FFTQJbWtuWGANFqxDzEH5NEV7/SfK+qTgAh931KyUw== react-native-safe-area-view@^0.14, react-native-safe-area-view@^0.14.8, react-native-safe-area-view@^0.14.9: version "0.14.9"