realm / realm-js

Realm is a mobile database: an alternative to SQLite & key-value stores
https://realm.io
Apache License 2.0
5.62k stars 558 forks source link

IOS Cannot load different react native js bundle #6553

Closed mereka-ta closed 1 month ago

mereka-ta commented 2 months ago

How frequently does the bug occur?

Always

Description

When realm is installed (only included in package.json, no usage in js yet) in React Native version 0.71 onwards with its compatible realm version.

After the app has successfully loaded, I cannot load another custom react native js bundle using initWithBundleURL :

    RCTRootView *rootView =
      [[RCTRootView alloc] initWithBundleURL: jsCodeLocation
                                   moduleName: @"HighScore"
                                   initialProperties:
                                     @{
                                       @"params" : @{
                                           @"action": @"HIGH_SCORE_SCREEN"
                                          }
                                     }
                                   launchOptions: nil];
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view = rootView;
    [self presentViewController:vc animated:YES completion:nil];

(Reference: React Native Official Documentation)

The main UIView turns blank in both Release & Debug build. In Debug, there is a message Connect to metro to develop javascript. No error message in the log, & the new bundle props is successfully logged.

I have tested various combination of RN version x Realm version. Everything works fine in RN pre-version-0.70.

✅ Last successfully test - RN v0.70.15 | Realm v11.3.1 ❌ First failed test - RN v0.71.0 | Realm v12.5.1

Stacktrace & log output

No response

Can you reproduce the bug?

Always

Reproduction Steps

Just include realm package in package.json for react native version 0.71.x onwards. Occurs in newer version of realm from 12.5.x until 12.6.0

Version

12.5.1

What services are you using?

Local Database only

Are you using encryption?

No

Platform OS and version(s)

IOS

Build environment

Which debugger for React Native: .. XCode version 14.3.1 Metro version 0.73.10

Cocoapods version

1.11.3

sync-by-unito[bot] commented 2 months ago

➤ PM Bot commented:

Jira ticket: RJS-2758

kneth commented 2 months ago

@mereka-ta We migrated away from rollup in v12.6.1, and I am curious if you observe the issue after upgrading to v12.6.1.

mereka-ta commented 2 months ago

@mereka-ta We migrated away from rollup in v12.6.1, and I am curious if you observe the issue after upgrading to v12.6.1.

Yup, it is still happening. I've just tested more version combination Realm version up to 12.6.2 & RN version up to 0.73.6.

I think every time the initWithBundleUrl or initWithBridge is called, realm need to trigger invokeAsync again. (abiding the flushing flow)

Unfortunately, I haven't got the time to find a workaround for now.

kraenhansen commented 2 months ago

We're not actively testing against brownfield applications, but I don't see any obvious reasons why it wouldn't work.

Following the steps you've outlined in "Reproduction Steps" is not enough for us, since our integration tests are already succeeding with React Native 0.73.2 and the latest version of Realm 12.6.2 (and main): It would help us immensely if you wanted to provide us with a repository which shows this error.

github-actions[bot] commented 1 month ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.