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 ReactActivity.getReactDelegate().reload() #44223

Closed
wants to merge 1 commit into from

Conversation

Kudo
Copy link
Contributor

@Kudo Kudo commented Apr 23, 2024

Summary:

fixing some problem for ReactActivity.getReactDelegate().reload() from #43521:

  • the reload() does not work for bridge mode on release build

Changelog:

[ANDROID] [FIXED] - Fixed app reloading for ReactActivity.getReactDelegate().reload().

Test Plan:

tried to temporary change toast.show as reload and test from rn-tester

--- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
 import android.view.Gravity
 import android.widget.Toast
 import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
 import com.facebook.react.bridge.NativeModule
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
       )

   override public fun show(message: String?, durationDouble: Double) {
-    val duration = durationDouble.toInt()
-    UiThreadUtil.runOnUiThread(
-        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+//    val duration = durationDouble.toInt()
+//    UiThreadUtil.runOnUiThread(
+//        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+    val activity = reactApplicationContext.currentActivity as? ReactActivity
+    activity?.reactDelegate?.reload()
   }

   override public fun showWithGravity(

tried for different mode

  • bridge mode + debug build
  • bridgeless mode + debug build
  • bridge mode + release build
  • bridgeless mode + release build

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Apr 23, 2024
@analysis-bot
Copy link

analysis-bot commented Apr 23, 2024

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,411,011 -11
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,784,348 +4
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 849da21
Branch: main

arushikesarwani94 added a commit to arushikesarwani94/react-native that referenced this pull request Apr 23, 2024
Summary: In facebook#44223 kudo identified the incorrect return type.

Differential Revision: D56497700
arushikesarwani94 added a commit to arushikesarwani94/react-native that referenced this pull request Apr 23, 2024
…ebook#44227)

Summary:

In facebook#44223 kudo identified the incorrect return type.

Differential Revision: D56497700
facebook-github-bot pushed a commit that referenced this pull request Apr 24, 2024
)

Summary:
Pull Request resolved: #44227

In #44223 kudo identified the incorrect return type.

Reviewed By: christophpurrer, philIip

Differential Revision: D56497700

fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
@Kudo Kudo force-pushed the @kudo/reload-fix branch from 627b779 to 4f5dd70 Compare April 24, 2024 13:26
@Kudo
Copy link
Contributor Author

Kudo commented Apr 24, 2024

rebase main since #44227 was landed

@facebook-github-bot
Copy link
Contributor

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

cipolleschi pushed a commit that referenced this pull request May 1, 2024
)

Summary:
Pull Request resolved: #44227

In #44223 kudo identified the incorrect return type.

Reviewed By: christophpurrer, philIip

Differential Revision: D56497700

fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 1, 2024
Copy link

github-actions bot commented May 1, 2024

This pull request was successfully merged by @Kudo in 5399223.

When will my fix make it into a release? | How to file a pick request?

@facebook-github-bot
Copy link
Contributor

@arushikesarwani94 merged this pull request in 5399223.

cipolleschi pushed a commit that referenced this pull request May 2, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from #43521:
- the `reload()` does not work for bridge mode on release build

[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.

Pull Request resolved: #44223

Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
 import android.view.Gravity
 import android.widget.Toast
 import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
 import com.facebook.react.bridge.NativeModule
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
       )

   override public fun show(message: String?, durationDouble: Double) {
-    val duration = durationDouble.toInt()
-    UiThreadUtil.runOnUiThread(
-        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+//    val duration = durationDouble.toInt()
+//    UiThreadUtil.runOnUiThread(
+//        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+    val activity = reactApplicationContext.currentActivity as? ReactActivity
+    activity?.reactDelegate?.reload()
   }

   override public fun showWithGravity(
```

tried for different mode
- [x] bridge mode + debug build
- [x] bridgeless mode + debug build
- [x] bridge mode + release build
- [x] bridgeless mode + release build

Reviewed By: fkgozali

Differential Revision: D56795975

Pulled By: arushikesarwani94

fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
…ebook#44227)

Summary:
Pull Request resolved: facebook#44227

In facebook#44223 kudo identified the incorrect return type.

Reviewed By: christophpurrer, philIip

Differential Revision: D56497700

fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request May 6, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from facebook#43521:
- the `reload()` does not work for bridge mode on release build

## Changelog:

[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.

Pull Request resolved: facebook#44223

Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
 import android.view.Gravity
 import android.widget.Toast
 import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
 import com.facebook.react.bridge.NativeModule
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
       )

   override public fun show(message: String?, durationDouble: Double) {
-    val duration = durationDouble.toInt()
-    UiThreadUtil.runOnUiThread(
-        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+//    val duration = durationDouble.toInt()
+//    UiThreadUtil.runOnUiThread(
+//        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+    val activity = reactApplicationContext.currentActivity as? ReactActivity
+    activity?.reactDelegate?.reload()
   }

   override public fun showWithGravity(
```

tried for different mode
- [x] bridge mode + debug build
- [x] bridgeless mode + debug build
- [x] bridge mode + release build
- [x] bridgeless mode + release build

Reviewed By: fkgozali

Differential Revision: D56795975

Pulled By: arushikesarwani94

fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
…ebook#44227)

Summary:
Pull Request resolved: facebook#44227

In facebook#44223 kudo identified the incorrect return type.

Reviewed By: christophpurrer, philIip

Differential Revision: D56497700

fbshipit-source-id: 5d7fc7ef21c3d3033a2567eba51b613eb41f0a1a
kosmydel pushed a commit to kosmydel/react-native that referenced this pull request Jun 11, 2024
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from facebook#43521:
- the `reload()` does not work for bridge mode on release build

## Changelog:

[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.

Pull Request resolved: facebook#44223

Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
 import android.view.Gravity
 import android.widget.Toast
 import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
 import com.facebook.react.bridge.NativeModule
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
       )

   override public fun show(message: String?, durationDouble: Double) {
-    val duration = durationDouble.toInt()
-    UiThreadUtil.runOnUiThread(
-        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+//    val duration = durationDouble.toInt()
+//    UiThreadUtil.runOnUiThread(
+//        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+    val activity = reactApplicationContext.currentActivity as? ReactActivity
+    activity?.reactDelegate?.reload()
   }

   override public fun showWithGravity(
```

tried for different mode
- [x] bridge mode + debug build
- [x] bridgeless mode + debug build
- [x] bridge mode + release build
- [x] bridgeless mode + release build

Reviewed By: fkgozali

Differential Revision: D56795975

Pulled By: arushikesarwani94

fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. Merged This PR has been merged. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants