expo-modules-core 57.0.20 → 57.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,24 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 57.0.22 — 2026-10-12
14
+
15
+ ### 🎉 New features
16
+
17
+ - Lay out `RNHostView` hosted content at the size SwiftUI or Compose gives it on an axis that `matchContents` does not match. ([#50674](https://github.com/expo/expo/pull/50674) by [@nishan](https://github.com/intergalacticspacehighway))
18
+
19
+ ### 🐛 Bug fixes
20
+
21
+ - [Android] Fix views sized by Jetpack Compose, such as `RNHostView` in a `ModalBottomSheet`, that kept their old size until the keyboard animation ended when the keyboard was dismissed with the predictive back gesture. ([#51083](https://github.com/expo/expo/pull/51083) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
22
+
23
+ ## 57.0.21 — 2026-10-06
24
+
25
+ ### 🐛 Bug fixes
26
+
27
+ - Fixed listeners removed with `subscription.remove()` never being garbage-collected, together with their emitter and everything their closure references, when the closure can reach the subscription (as in `useEvent`, `useEventListener` or a `useEffect` that returns `() => subscription.remove()`). ([#50603](https://github.com/expo/expo/pull/50603) by [@gkueny](https://github.com/gkueny))
28
+ - [iOS] Fixed a crash (`The app context has been lost`) when an Expo view mounts during a reload. ([#50721](https://github.com/expo/expo/pull/50721) by [@tsapeta](https://github.com/tsapeta))
29
+ - [Android] Fixed Expo views using Android layout not completing system-forced layout passes. ([#48679](https://github.com/expo/expo/pull/48679) by [@lujjjh](https://github.com/lujjjh))
30
+
13
31
  ## 57.0.20 — 2026-09-29
14
32
 
15
33
  ### 🐛 Bug fixes
@@ -27,7 +27,7 @@ if (shouldIncludeCompose) {
27
27
  }
28
28
 
29
29
  group = 'host.exp.exponent'
30
- version = '57.0.20'
30
+ version = '57.0.22'
31
31
 
32
32
  def isExpoModulesCoreTests = {
33
33
  Gradle gradle = getGradle()
@@ -94,7 +94,7 @@ android {
94
94
  defaultConfig {
95
95
  consumerProguardFiles 'proguard-rules.pro'
96
96
  versionCode 1
97
- versionName "57.0.20"
97
+ versionName "57.0.22"
98
98
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
99
99
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
100
100
 
@@ -2,7 +2,6 @@ package expo.modules.kotlin.views
2
2
 
3
3
  import android.annotation.SuppressLint
4
4
  import android.content.Context
5
- import android.content.res.Configuration
6
5
  import android.util.Log
7
6
  import android.view.View
8
7
  import android.view.ViewGroup
@@ -114,15 +113,6 @@ abstract class ExpoComposeView<T : ComposeProps>(
114
113
  }
115
114
  }
116
115
 
117
- override fun dispatchConfigurationChanged(newConfig: Configuration) {
118
- super.dispatchConfigurationChanged(newConfig)
119
- // React Native owns this view's bounds and may not schedule another Android layout pass
120
- // when a configuration change leaves its Yoga layout unchanged.
121
- if (withHostingView && isAttachedToWindow && isLaidOut) {
122
- requestLayout()
123
- }
124
- }
125
-
126
116
  /**
127
117
  * Validates that this non-hosting Compose view has a valid Compose parent.
128
118
  *
@@ -35,7 +35,8 @@ abstract class ExpoView(
35
35
 
36
36
  /**
37
37
  * Manually trigger measure and layout.
38
- * If [shouldUseAndroidLayout] is set to `true`, this method will be called automatically after [requestLayout].
38
+ * If [shouldUseAndroidLayout] is set to `true`, this method will be called automatically after
39
+ * [requestLayout] or [forceLayout].
39
40
  */
40
41
  @UiThread
41
42
  fun measureAndLayout() {
@@ -54,6 +55,19 @@ abstract class ExpoView(
54
55
  }
55
56
  }
56
57
 
58
+ override fun forceLayout() {
59
+ super.forceLayout()
60
+ if (shouldUseAndroidLayout && isAttachedToWindow && isLaidOut) {
61
+ // ViewRootImpl can force-layout the hierarchy without React Native laying out its
62
+ // managed children. Preserve the Android-layout contract at that boundary.
63
+ post {
64
+ if (isAttachedToWindow && isLayoutRequested) {
65
+ measureAndLayout()
66
+ }
67
+ }
68
+ }
69
+ }
70
+
57
71
  open fun clipToPaddingBox(canvas: Canvas) {
58
72
  // When the border radius is set, we need to clip the content to the padding box.
59
73
  // This is because the border radius is applied to the background drawable, not the view itself.
@@ -1,7 +1,9 @@
1
1
  package expo.modules.kotlin.views
2
2
 
3
3
  import android.view.ViewTreeObserver
4
+ import androidx.annotation.UiThread
4
5
  import expo.modules.kotlin.jni.fabric.NativeStatePropsGetter
6
+ import kotlinx.coroutines.launch
5
7
  import java.lang.ref.WeakReference
6
8
 
7
9
  class ShadowNodeProxy(expoView: ExpoView) {
@@ -10,18 +12,24 @@ class ShadowNodeProxy(expoView: ExpoView) {
10
12
 
11
13
  private var pendingFlush: ((stateWrapper: Any) -> Unit)? = null
12
14
  private var preDrawListener: ViewTreeObserver.OnPreDrawListener? = null
13
- private val flushRunnable = Runnable { drainPendingFlush() }
15
+ private var flushPosted = false
16
+ private val flushRunnable = Runnable {
17
+ flushPosted = false
18
+ drainPendingFlush()
19
+ }
14
20
 
15
21
  // Schedule in predraw listener to avoid early return in re-entrancy
16
22
  // We have a proper fix [here](https://github.com/facebook/react-native/pull/56311)
17
23
  // but it needs to be merged in RN
18
24
  // TODO: Remove the workaround when RN PR gets merged.
25
+ @UiThread
19
26
  fun setViewSize(width: Double, height: Double) {
20
27
  scheduleFlush { stateWrapper ->
21
28
  stateUpdater.updateViewSizeImmediate(stateWrapper, width, height)
22
29
  }
23
30
  }
24
31
 
32
+ @UiThread
25
33
  fun setStyleSize(width: Double?, height: Double?) {
26
34
  scheduleFlush { stateWrapper ->
27
35
  stateUpdater.updateStyleSizeImmediate(stateWrapper, width ?: Double.NaN, height ?: Double.NaN)
@@ -68,8 +76,18 @@ class ShadowNodeProxy(expoView: ExpoView) {
68
76
 
69
77
  // Predraw listener do not get called for each keyboard transition event so we add a fallback flush to be called here
70
78
  // https://github.com/expo/expo/issues/47778
71
- view.removeCallbacks(flushRunnable)
72
- view.post(flushRunnable)
79
+ // Async and posted once, so it still runs during animations.
80
+ // `Dispatchers.Main` posts async messages, which skip the traversal sync barriers.
81
+ // https://github.com/expo/expo/issues/51034
82
+ if (!flushPosted) {
83
+ flushPosted = true
84
+ if (view.isAttachedToWindow) {
85
+ view.appContext.mainQueue.launch { flushRunnable.run() }
86
+ } else {
87
+ // `view.post` keeps the runnable until the view attaches.
88
+ view.post(flushRunnable)
89
+ }
90
+ }
73
91
  }
74
92
 
75
93
  private fun drainPendingFlush() {
@@ -188,10 +188,20 @@ jsi::Value createEventSubscription(jsi::Runtime &runtime, const std::string &eve
188
188
  std::shared_ptr<jsi::Value> listenerValue = std::make_shared<jsi::Value>(runtime, listener);
189
189
 
190
190
  jsi::HostFunctionType removeSubscription = [eventName, emitterValue, listenerValue](jsi::Runtime &runtime, const jsi::Value &thisValue, const jsi::Value *args, size_t count) -> jsi::Value {
191
+ if (!listenerValue->isObject()) {
192
+ // The subscription has already been removed.
193
+ return jsi::Value::undefined();
194
+ }
191
195
  jsi::Object emitter = emitterValue->getObject(runtime);
192
196
  jsi::Function listener = listenerValue->getObject(runtime).getFunction(runtime);
193
197
 
194
198
  removeListener(runtime, emitter, eventName, listener);
199
+
200
+ // Values held by this host function are GC roots. The listener's closure often references the subscription
201
+ // (e.g. a React effect returning `() => subscription.remove()`), so keeping them after the removal would form
202
+ // a cycle through a root that the garbage collector can never break, leaking the listener and the emitter.
203
+ *emitterValue = jsi::Value::undefined();
204
+ *listenerValue = jsi::Value::undefined();
195
205
  return jsi::Value::undefined();
196
206
  };
197
207
 
@@ -61,17 +61,47 @@ public:
61
61
 
62
62
  const auto snode = dynamic_cast<ShadowNodeType *>(&shadowNode);
63
63
  const auto state = snode->getStateData();
64
+ auto const &sharedProps = snode->getProps();
65
+ auto &style = const_cast<facebook::yoga::Style &>(
66
+ static_cast<const facebook::react::ViewProps &>(*sharedProps).yogaStyle);
67
+ bool propsStyleChanged = false;
64
68
 
69
+ if (isRNHostView(sharedProps)) {
70
+ // If RNHostView has align self set to auto or stretch, we should override it to flex-start so that the node can size itself to its content
71
+ auto const alignSelf = style.alignSelf();
72
+
73
+ if (alignSelf == facebook::yoga::Align::Auto || alignSelf == facebook::yoga::Align::Stretch) {
74
+ style.setAlignSelf(facebook::yoga::Align::FlexStart);
75
+ propsStyleChanged = true;
76
+ }
77
+ }
78
+
79
+ // handle layout style prop update
80
+ if (!isnan(state._styleWidth)) {
81
+ style.setDimension(facebook::yoga::Dimension::Width,
82
+ facebook::yoga::StyleSizeLength::points(state._styleWidth));
83
+ propsStyleChanged = true;
84
+ }
85
+
86
+ if (!isnan(state._styleHeight)) {
87
+ style.setDimension(facebook::yoga::Dimension::Height,
88
+ facebook::yoga::StyleSizeLength::points(state._styleHeight));
89
+ propsStyleChanged = true;
90
+ }
91
+
92
+ if (propsStyleChanged) {
93
+ // Updates yoga style from props and sets the node dirty
94
+ snode->updateYogaProps();
95
+ }
96
+
97
+ // Writes the node style directly, so it runs last.
65
98
  auto width = state._width;
66
99
  auto height = state._height;
67
100
 
68
101
  if (!isnan(width) || !isnan(height)) {
69
- auto const &props = *std::static_pointer_cast<const facebook::react::ViewProps>(
70
- snode->getProps());
71
-
72
102
  // The node has width and/or height set as style props, so we should not override it
73
- auto widthProp = props.yogaStyle.dimension(facebook::yoga::Dimension::Width);
74
- auto heightProp = props.yogaStyle.dimension(facebook::yoga::Dimension::Height);
103
+ auto widthProp = style.dimension(facebook::yoga::Dimension::Width);
104
+ auto heightProp = style.dimension(facebook::yoga::Dimension::Height);
75
105
 
76
106
  if (widthProp.value().isDefined()) {
77
107
  // view has fixed dimension size set in props, so we should not autosize it in that axis
@@ -84,44 +114,6 @@ public:
84
114
  snode->setSize({width, height});
85
115
  }
86
116
 
87
- // handle layout style prop update
88
- auto styleWidth = state._styleWidth;
89
- auto styleHeight = state._styleHeight;
90
-
91
- if (!isnan(styleWidth) || !isnan(styleHeight)) {
92
- auto const &props = *std::static_pointer_cast<const facebook::react::ViewProps>(
93
- snode->getProps());
94
-
95
- auto &style = const_cast<facebook::yoga::Style &>(props.yogaStyle);
96
-
97
- if (!isnan(styleWidth)) {
98
- style.setDimension(facebook::yoga::Dimension::Width,
99
- facebook::yoga::StyleSizeLength::points(styleWidth));
100
- }
101
-
102
- if (!isnan(styleHeight)) {
103
- style.setDimension(facebook::yoga::Dimension::Height,
104
- facebook::yoga::StyleSizeLength::points(styleHeight));
105
- }
106
-
107
- // Updates yoga style from props and sets the node dirty
108
- snode->updateYogaProps();
109
- }
110
-
111
- if (isRNHostView(snode->getProps())) {
112
- auto const &props = *std::static_pointer_cast<const facebook::react::ViewProps>(
113
- snode->getProps());
114
- auto &style = const_cast<facebook::yoga::Style &>(props.yogaStyle);
115
-
116
- // If RNHostView has align self set to auto or stretch, we should override it to flex-start so that the node can size itself to its content
117
- auto const alignSelf = style.alignSelf();
118
-
119
- if (alignSelf == facebook::yoga::Align::Auto || alignSelf == facebook::yoga::Align::Stretch) {
120
- style.setAlignSelf(facebook::yoga::Align::FlexStart);
121
- snode->updateYogaProps();
122
- }
123
- }
124
-
125
117
  facebook::react::ConcreteComponentDescriptor<ShadowNodeType>::adopt(shadowNode);
126
118
  }
127
119
  };
@@ -163,6 +163,20 @@ private:
163
163
  }
164
164
 
165
165
  react::LayoutConstraints hostedContentConstraints(const react::ShadowNode &content) const {
166
+ auto constraints = contentStyleConstraints(content);
167
+
168
+ // An unmatched axis has the size SwiftUI or Compose gave the host (from `setViewSize`), so lay
169
+ // the content out at exactly that size. This overrides the content's own min/max on that axis.
170
+ auto const &ownStyle = this->yogaNode_.style();
171
+ constrainExactlyToPoints(ownStyle.dimension(facebook::yoga::Dimension::Width),
172
+ constraints.minimumSize.width, constraints.maximumSize.width);
173
+ constrainExactlyToPoints(ownStyle.dimension(facebook::yoga::Dimension::Height),
174
+ constraints.minimumSize.height, constraints.maximumSize.height);
175
+
176
+ return constraints;
177
+ }
178
+
179
+ react::LayoutConstraints contentStyleConstraints(const react::ShadowNode &content) const {
166
180
  react::LayoutConstraints constraints{};
167
181
  constraints.layoutDirection = resolvedLayoutDirection();
168
182
 
@@ -186,6 +200,14 @@ private:
186
200
  return constraints;
187
201
  }
188
202
 
203
+ static void constrainExactlyToPoints(facebook::yoga::StyleSizeLength length,
204
+ react::Float &minimum,
205
+ react::Float &maximum) {
206
+ if (length.isPoints() && length.value().isDefined()) {
207
+ minimum = maximum = std::max<react::Float>(0, length.value().unwrap());
208
+ }
209
+ }
210
+
189
211
  static void constrainToPoints(facebook::yoga::StyleSizeLength length, react::Float &constraint) {
190
212
  if (length.isPoints() && length.value().isDefined()) {
191
213
  constraint = std::max<react::Float>(0, length.value().unwrap());
@@ -120,17 +120,30 @@ public final class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendab
120
120
  }
121
121
  }
122
122
 
123
- /**
124
- The application identifier that is used to distinguish between different `RCTHost`.
125
- It might be equal to `nil`, meaning we couldn't obtain the Id for the current app.
126
- It shouldn't be used on the old architecture.
127
- */
123
+ /// The number of app contexts created so far in this process.
124
+ private static let appContextsCount = Mutex<Int>(0)
125
+
126
+ /// The position of this app context in creation order, starting at 0.
127
+ internal let appIndex: Int = AppContext.appContextsCount.withLock { count in
128
+ defer {
129
+ count += 1
130
+ }
131
+ return count
132
+ }
133
+
134
+ /// The application identifier that distinguishes app contexts that are alive at the same time,
135
+ /// for example during a reload or when more than one `RCTHost` is running. It's `nil` for the first
136
+ /// app context, so its view names have no suffix.
128
137
  @objc
129
138
  public var appIdentifier: String? {
130
- guard let moduleRegistry = reactBridge?.moduleRegistry else {
139
+ return AppContext.appIdentifier(forIndex: appIndex)
140
+ }
141
+
142
+ internal static func appIdentifier(forIndex index: Int) -> String? {
143
+ if index == 0 {
131
144
  return nil
132
145
  }
133
- return "\(abs(ObjectIdentifier(moduleRegistry).hashValue))"
146
+ return String(index)
134
147
  }
135
148
 
136
149
  /**
@@ -18,7 +18,12 @@
18
18
  @compatibility_alias UIImage NSImage;
19
19
  @compatibility_alias UIImageView NSImageView;
20
20
 
21
- #ifndef UIApplication
21
+ // `@compatibility_alias` doesn't define a preprocessor macro, so `#ifndef
22
+ // UIApplication` never detected that `React/RCTUIKit.h` (imported above)
23
+ // already declares this same alias. Under Swift Explicit Modules, that
24
+ // duplicate declaration becomes a real Clang conflict. Guard on the
25
+ // header's presence instead.
26
+ #if !__has_include(<React/RCTUIKit.h>)
22
27
  @compatibility_alias UIApplication NSApplication;
23
28
  #endif
24
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "57.0.20",
3
+ "version": "57.0.22",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@expo/expo-modules-macros-plugin": "0.6.1",
50
- "expo-modules-jsi": "~57.1.1",
50
+ "expo-modules-jsi": "~57.1.2",
51
51
  "invariant": "^2.2.4"
52
52
  },
53
53
  "peerDependencies": {
@@ -66,7 +66,7 @@
66
66
  "@types/invariant": "^2.2.33",
67
67
  "expo-module-scripts": "56.0.3"
68
68
  },
69
- "gitHead": "ad1efa3fa5802156660198ba5d787f91014d8df3",
69
+ "gitHead": "58da4edafcb043872c3ed9bf8f5957e6544d0a9c",
70
70
  "scripts": {
71
71
  "build": "expo-module build",
72
72
  "clean": "expo-module clean",