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

bugfix: persist not working on iOS #836

Merged
merged 4 commits into from
Jun 14, 2023
Merged

Conversation

jmyrland
Copy link
Collaborator

@jmyrland jmyrland commented Jun 12, 2023

createPersistor defines a timingMethod that won't work on iOS.

This is because this method utilizes requestIdleCallback, which is defined on iOS - but never invoked 🤯

So, for iOS we have to fallback to utilize requestAnimationFrame. This is done by vendoring a specific file timingMethod.ios.js, which the RN bundle can import for the iOS platform.

It turns out that the pollyfilled requestIdleCallback for RN on iOS, requires a second parameter with a specific timeout - where as the native implementation does not. Setting the specific parameter invokes this function across all platforms.

fixes #694
fixes #599

`createPersistor` defines a `timingMethod` that won't work on iOS.

This is because this method utilizes `requestIdleCallback`, which is
defined on iOS - but never invoked 🤯

So, for iOS we have to fallback to utilize `requestAnimationFrame`.
This is done by vendoring a specific file `timingMethod.ios.js`, which
the RN bundle can import for the iOS platform.
@vercel
Copy link

vercel bot commented Jun 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
easy-peasy ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 14, 2023 2:28pm

@jmyrland
Copy link
Collaborator Author

I'm not able to verify if this is working, as I currently don't have a mac to test this on :/

@jmyrland
Copy link
Collaborator Author

Verified and tested on https://snack.expo.dev/_fo68oUf7

Notice how SET_ITEM is logged for all platforms.

@jmyrland jmyrland changed the title [Bugfix] persist not working on iOS bugfix: persist not working on iOS Jun 14, 2023
Copy link
Collaborator

@no-stack-dub-sack no-stack-dub-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jmyrland jmyrland merged commit 76226a7 into master Jun 14, 2023
@jmyrland jmyrland deleted the bugfix/ios-timing-method branch June 14, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants