Skip to content

Commit

Permalink
fix: android app crash (#10798)
Browse files Browse the repository at this point in the history
* fix: android app crash

* chore: try to revert reanimated

* chore: try to revert reanimated

* chore: revert unrelated changes

* bump palette to right version with 3.3.0 reanimated

* refresh ios cache

* bring back patch reanimated

* fix patch reanimated

* fix patch reanimated

* bring back rosetta
  • Loading branch information
gkartalis authored Sep 18, 2024
1 parent e6a6152 commit 4a6afe4
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 43 deletions.
6 changes: 4 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ commands:
steps:
- restore_cache:
keys:
- v19-app_build_ios-{{ checksum ".manifests/app_build" }}
- v21-app_build_ios-{{ checksum ".manifests/app_build" }}
- run:
name: Download fonts from s3
command: ./scripts/setup/download-fonts
Expand All @@ -109,7 +109,7 @@ commands:
name: Build App
command: ./scripts/ci/ci-ios
- save_cache:
key: v19-app_build_ios-{{ checksum ".manifests/app_build" }}
key: v21-app_build_ios-{{ checksum ".manifests/app_build" }}
paths:
- derived_data
- node_modules/react-native-config
Expand Down Expand Up @@ -412,6 +412,7 @@ jobs:
platform: "iOS"
device: "iPhone 15 Pro"
- build-app-ios
- macos/install-rosetta
- run:
name: Run tests if native code has changed
command: ls xcode_test_raw.log || ./scripts/ci/ci-test-ios
Expand Down Expand Up @@ -515,6 +516,7 @@ jobs:
- update-echo
- install-gems
- install-cocoapods
- macos/install-rosetta
- run:
name: Upload iOS build to Maestro App Quality Copilot
no_output_timeout: 20m
Expand Down
10 changes: 10 additions & 0 deletions HACKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ https://github.com/SwiftyJSON/SwiftyJSON/issues/1154
Apples has started requiring apps and certain 3rd party libraries declare in a privacy manifest why they use some apis, SwiftyJSON is one of them. The
privacy manifest has been added in 5.0.2 but the version has not been published to cocoapods.

## Patch-package for react-native-reanimated

#### When can we remove this:

When we upgrade to Reanimated 3.4.0

#### Explanation/Context:

Fixes some issues on Android when Reanimated stops. https://github.com/software-mansion/react-native-reanimated/issues/4626

## Patch-package for react-native-fast-image

#### When we can remove this:
Expand Down
31 changes: 28 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -816,10 +816,35 @@ PODS:
- React-Core
- RNReactNativeHapticFeedback (1.13.0):
- React-Core
- RNReanimated (3.6.3):
- RCT-Folly (= 2021.07.22.00)
- RNReanimated (3.3.0):
- DoubleConversion
- FBLazyVector
- glog
- hermes-engine
- RCT-Folly
- RCTRequired
- RCTTypeSafety
- React-callinvoker
- React-Core
- React-Core/DevSupport
- React-Core/RCTWebSocket
- React-CoreModules
- React-cxxreact
- React-hermes
- React-jsi
- React-jsiexecutor
- React-jsinspector
- React-RCTActionSheet
- React-RCTAnimation
- React-RCTAppDelegate
- React-RCTBlob
- React-RCTImage
- React-RCTLinking
- React-RCTNetwork
- React-RCTSettings
- React-RCTText
- ReactCommon/turbomodule/core
- Yoga
- RNScreens (3.29.0):
- RCT-Folly (= 2021.07.22.00)
- React-Core
Expand Down Expand Up @@ -1515,7 +1540,7 @@ SPEC CHECKSUMS:
RNLocalize: 6351aa411de4283a753a2946e21a77d1b9e271e3
RNPermissions: 23abdfa77d3cd3700b181a2d47f29939c6878ce6
RNReactNativeHapticFeedback: b83bfb4b537bdd78eb4f6ffe63c6884f7b049ead
RNReanimated: 548e621fe2e12b6bdccbc48ed5e5361d9822c775
RNReanimated: 9f7068e43b9358a46a688d94a5a3adb258139457
RNScreens: 8ba3eeb8f5cb9f13662df564e785d64ef7214bf2
RNSentry: e9aa15bb2f3e18c822c002eea13bbd3b222ab493
RNShare: 859ff710211285676b0bcedd156c12437ea1d564
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
},
"dependencies": {
"@artsy/cohesion": "4.204.0",
"@artsy/palette-mobile": "13.2.30",
"@artsy/palette-mobile": "13.2.31",
"@artsy/to-title-case": "1.1.0",
"@braze/react-native-sdk": "5.2.0",
"@expo/react-native-action-sheet": "4.0.1",
Expand Down Expand Up @@ -177,7 +177,7 @@
"react-native-pager-view": "6.2.0",
"react-native-permissions": "3.8.4",
"react-native-push-notification": "8.1.1",
"react-native-reanimated": "3.6.3",
"react-native-reanimated": "3.3.0",
"react-native-reanimated-zoom": "0.3.3",
"react-native-render-html": "6.3.4",
"react-native-safe-area-context": "3.4.0",
Expand Down
54 changes: 54 additions & 0 deletions patches/react-native-reanimated+3.3.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
diff --git a/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java b/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
index e974f8e..f18d93d 100644
--- a/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
+++ b/node_modules/react-native-reanimated/android/src/main/java/com/swmansion/reanimated/NodesManager.java
@@ -81,7 +81,7 @@ public class NodesManager implements EventDispatcherListener {
private RCTEventEmitter mCustomEventHandler;
private List<OnAnimationFrame> mFrameCallbacks = new ArrayList<>();
private ConcurrentLinkedQueue<CopiedEvent> mEventQueue = new ConcurrentLinkedQueue<>();
- public double currentFrameTimeMs;
+ private double lastFrameTimeMs;
public Set<String> uiProps = Collections.emptySet();
public Set<String> nativeProps = Collections.emptySet();
private ReaCompatibility compatibility;
@@ -234,22 +234,27 @@ public class NodesManager implements EventDispatcherListener {
}

private void onAnimationFrame(long frameTimeNanos) {
- currentFrameTimeMs = frameTimeNanos / 1000000.;
-
- while (!mEventQueue.isEmpty()) {
- CopiedEvent copiedEvent = mEventQueue.poll();
- handleEvent(copiedEvent.getTargetTag(), copiedEvent.getEventName(), copiedEvent.getPayload());
- }
+ double currentFrameTimeMs = frameTimeNanos / 1000000.;
+
+ if (currentFrameTimeMs > lastFrameTimeMs) {
+ // It is possible for ChoreographerCallback to be executed twice within the same frame
+ // due to frame drops. If this occurs, the additional callback execution should be ignored.
+ lastFrameTimeMs = currentFrameTimeMs;
+ while (!mEventQueue.isEmpty()) {
+ CopiedEvent copiedEvent = mEventQueue.poll();
+ handleEvent(copiedEvent.getTargetTag(), copiedEvent.getEventName(), copiedEvent.getPayload());
+ }

- if (!mFrameCallbacks.isEmpty()) {
- List<OnAnimationFrame> frameCallbacks = mFrameCallbacks;
- mFrameCallbacks = new ArrayList<>(frameCallbacks.size());
- for (int i = 0, size = frameCallbacks.size(); i < size; i++) {
- frameCallbacks.get(i).onAnimationFrame(currentFrameTimeMs);
+ if (!mFrameCallbacks.isEmpty()) {
+ List<OnAnimationFrame> frameCallbacks = mFrameCallbacks;
+ mFrameCallbacks = new ArrayList<>(frameCallbacks.size());
+ for (int i = 0, size = frameCallbacks.size(); i < size; i++) {
+ frameCallbacks.get(i).onAnimationFrame(currentFrameTimeMs);
+ }
}
- }

- performOperations();
+ performOperations();
+ }

mCallbackPosted.set(false);

47 changes: 11 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
dependencies:
core-js "3"

"@artsy/[email protected].30":
version "13.2.30"
resolved "https://registry.yarnpkg.com/@artsy/palette-mobile/-/palette-mobile-13.2.30.tgz#5fdd580f3b94c54a3416d1b090043dec1a6ab828"
integrity sha512-SitUeGcuH/nvMZcc2XXBNY9szhIeBIZGwouaYEBO2kn3tW4ClZ0vSedq6qLCzBE48SuEWyCI8ej2CQR08t93Fw==
"@artsy/[email protected].31":
version "13.2.31"
resolved "https://registry.yarnpkg.com/@artsy/palette-mobile/-/palette-mobile-13.2.31.tgz#d927c080677edc66e6edbf53119974e7551f0bd9"
integrity sha512-V/51D8SO7kBWIZn134Hn3ZDNm12rvung3xYt7F1Yoepw/1+8GnOagOtOjAf6eWlkZTWlbP+xbVW8fOWo1Nv2nQ==
dependencies:
"@artsy/palette-tokens" "^6.0.3"
"@shopify/flash-list" "^1.6.4"
Expand Down Expand Up @@ -12692,10 +12692,10 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react-native-reanimated-zoom/-/react-native-reanimated-zoom-0.3.3.tgz#99161310c398b2d4220e75ce1d9b76eb075bf3f6"
integrity sha512-naeMV19218OsVOAw7jq45mZGxcSgvcn5xAJlXep27R0IBo/fqpLlLuXKK2nyCXyLzuIPwgqS3O+LUMcTd2L5Gg==

react-native-reanimated@3.6.3:
version "3.6.3"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.6.3.tgz#859cf2320e37c80e3a21e19db24f82c34d6d3ded"
integrity sha512-2KkkPozoIvDbJcHuf8qeyoLROXQxizSi+2CTCkuNVkVZOxxY4B0Omvgq61aOQhSZUh/649x1YHoAaTyGMGDJUw==
react-native-reanimated@3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.3.0.tgz#80f9d58e28fddf62fe4c1bc792337b8ab57936ab"
integrity sha512-LzfpPZ1qXBGy5BcUHqw3pBC0qSd22qXS3t8hWSbozXNrBkzMhhOrcILE/nEg/PHpNNp1xvGOW8NwpAMF006roQ==
dependencies:
"@babel/plugin-transform-object-assign" "^7.16.7"
"@babel/preset-typescript" "^7.16.7"
Expand Down Expand Up @@ -13989,16 +13989,7 @@ string-natural-compare@^3.0.1:
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -14112,7 +14103,7 @@ stringify-entities@^3.1.0:
character-entities-legacy "^1.0.0"
xtend "^4.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -14126,13 +14117,6 @@ strip-ansi@^5.0.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2"
Expand Down Expand Up @@ -15496,7 +15480,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.4.tgz#cb4b50ec9aca570abd1f52f33cd45b6c61739a9f"
integrity sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -15514,15 +15498,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 4a6afe4

Please sign in to comment.