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

iOS v10.20.0-beta.2 Flexible sync: subscriptions.update crashes after token expiry #4421

Closed
Joelfrewy opened this issue Mar 16, 2022 · 4 comments · Fixed by #4460
Closed
Assignees

Comments

@Joelfrewy
Copy link

Joelfrewy commented Mar 16, 2022

How frequently does the bug occur?

All the time

Description

Initialising realm subscriptions with flexible sync on iOS results in a crash. This crash only occurs roughly 30 mins after initially logging in (surely due to token expiration?). running refreshCustomData() before updating subscriptions fixes the issue, however this function requires internet access which could brick an offline app.

Stacktrace & log output

OS Version: iOS 15.3.1 (19D52)
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: BUS_NOOP
Crashed Thread: 7

Application Specific Information:
ZTUM >
Attempted to dereference null pointer.

Thread 7 Crashed:
0   app   0x2030f16dc   realm::sync::Session::on_new_flx_sync_subscription
1   app   0x2030424a0   realm::util::UniqueFunction<T>::make_impl<T>::SpecificImpl::call
2   app   0x2030424a0   realm::util::UniqueFunction<T>::make_impl<T>::SpecificImpl::call
3   app   0x203132720   realm::sync::MutableSubscriptionSet::commit
4   app   0x202f10ae0   realm::js::SubscriptionSetClass<T>::update
5   app   0x202f10774   realm::js::wrap<T>

Can you reproduce the bug?

Yes, always

Reproduction Steps

const initialise = async () => {
  const appConfig = {
    id: '<app id>',
    timeout: 10000,
  };
  const app = new Realm.App(appConfig);
  let user = app.currentUser;
  if (!user || user?.state !== 'active') {
    const credentials = Realm.Credentials.anonymous();
    user = await app.logIn(credentials);
  }
  // await app.currentUser?.refreshCustomData();      <-- This line fixes the null pointer issue but requires internet
  const realm = new Realm({
    schema: [...],
    sync: {
      user: app.currentUser,
      flexible: true,
    },
  });
  realm.subscriptions.update(mutableSubscriptions => {
    realm.schema.forEach(schema => {
      mutableSubscriptions.add(
        realm.objects(schema.name).filtered('userId = $0', user!.id),
        {
          name: schema.name,
        },
      );
    });
  });
}

Version

v10.20.0-beta.2 Hermes

What SDK flavour are you using?

MongoDB Realm (i.e. Sync, auth, functions)

Are you using encryption?

No, not using encryption

Platform OS and version(s)

iOS 15.3.1

Build environment

Release Mode

Cocoapods version

1.11.2

@fronck
Copy link

fronck commented Mar 16, 2022

@Joelfrewy Thank you for reporting this issue.
We will investigate how to address it.

@rklubenspies
Copy link

rklubenspies commented Mar 18, 2022

We're experiencing a similar issue on realm-swift v10.24.1.

@danieltabacaru
Copy link

Hi @Joelfrewy. Thanks for filling the bug. We identified the problem and it will be fixed by #5343.

@tomduncalf
Copy link
Contributor

Waiting on new core release to get this fix into Realm JS

tomduncalf pushed a commit that referenced this issue Mar 30, 2022
tomduncalf pushed a commit that referenced this issue Mar 30, 2022
tomduncalf pushed a commit that referenced this issue Mar 30, 2022
kneth added a commit that referenced this issue Apr 8, 2022
* Update core to v11.13.0
* Closes #4421
* Update podspec to include libcompression
* Update CHANGELOG.md

Co-authored-by: Kenneth Geisshirt <[email protected]>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
@sync-by-unito sync-by-unito bot changed the title iOS v10.20.0-beta.2 Flexible sync: subscriptions.update crashes after token expiry iOS v10.20.0-beta.2 Flexible sync: subscriptions.update crashes after token expiry Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants