Skip to content

Update react-native example to expo@46#3934

Closed
hrougier wants to merge 1 commit intopubkey:masterfrom
hrougier:update-react-native-example
Closed

Update react-native example to expo@46#3934
hrougier wants to merge 1 commit intopubkey:masterfrom
hrougier:update-react-native-example

Conversation

@hrougier
Copy link

@hrougier hrougier commented Aug 15, 2022

I did this in the premium task context before seeing someone else submitted another PR :/

This PR contains:

  • Update to latest expo@46
  • Update of configuration files and dependencies based on the latest create-expo-app templates (.gitignore, app.json, icons, splashscreen image...)
  • Usage of expo-splash-screen while database is being initialized
  • Usage of .expo-shared for assets (npx expo-optimize)
  • usage of text-encoding-polyfill to avoid app crashing (rxdb uses the TextEncoder class from DOM)
  • Support for hot reloading (avoid an rxdb error where the db got reinitialized on each hot reloading)
  • Removed no longer needed dependencies from package.json
  • Some code refactoring to improve readability (src folder and some others)
  • Update screenshot with latest iPhone simulator
  • added a .nvmrc file pointing to v16 because expo-cli does not support v18

Example is now fully working on a simulator.

Describe the problem you have without this PR

  • Example is not working (expo@43 not longer supported by ExpoGo) and crashes for various reasons enumerated above)

Some remaining issues

  • Git sees some moved files as deleted/recreated (sorry!)
  • Console errors during jest testing because setState is being called after it finished its test (it finishes before the splashscreen is hidden)
  • Testing the app render after the splashscreen is hidden cannot be done because of a segmentation fault likely due to this issue with dynamic imports, below is the crash report when you try to do so

PID 86695 received SIGSEGV for address: 0x0
0 segfault-handler.node 0x0000000108cb134c _ZL16segfault_handleriP9__siginfoPv + 288
1 libsystem_platform.dylib 0x00000001ac4354c4 _sigtramp + 56
2 node 0x0000000104215a88 _ZN4node6loaderL23ImportModuleDynamicallyEN2v85LocalINS1_7ContextEEENS2_INS1_14ScriptOrModuleEEENS2_INS1_6StringEEENS2_INS1_10FixedArrayEEE + 236
3 node 0x00000001044bfabc _ZN2v88internal7Isolate38RunHostImportModuleDynamicallyCallbackENS0_6HandleINS0_6ScriptEEENS2_INS0_6ObjectEEENS0_11MaybeHandleIS5_EE + 248
4 node 0x0000000104835254 _ZN2v88internal25Runtime_DynamicImportCallEiPmPNS0_7IsolateE + 396
5 node 0x0000000104b44e44 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvInRegister_NoBuiltinExit + 100
6 node 0x0000000104bd3218 Builtins_CallRuntimeHandler + 88
7 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
8 node 0x0000000104b0a02c Builtins_GeneratorPrototypeNext + 140
9 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
10 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
11 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
12 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
13 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
14 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
15 node 0x0000000104ad5858 construct_stub_create_deopt_addr + 344
16 node 0x0000000104bd3bb0 Builtins_ConstructHandler + 656
17 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
18 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
19 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
20 node 0x0000000104b0a02c Builtins_GeneratorPrototypeNext + 140
21 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
22 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
23 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
24 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
25 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
26 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
27 node 0x0000000104ad5858 construct_stub_create_deopt_addr + 344
28 node 0x0000000104bd3bb0 Builtins_ConstructHandler + 656
29 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
30 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248
31 node 0x0000000104ad8858 Builtins_InterpreterEntryTrampoline + 248

@hrougier hrougier force-pushed the update-react-native-example branch from 375454a to 7bca6ef Compare August 16, 2022 22:10
@hrougier
Copy link
Author

So I've fixed the App.test.js the best I could 😅 (found the await new Promise(setImmediate) trick on several stackoverflows looking for how to test an async useEffect).

Let me know if there are things to improve/not ok.

Not sure if the memory adapter is a good choice as the database does not persist (not a real usecase).
Otherwise it seems like a good example for people wanting to start using rxdb in expo with up to date templates and best pratices like integrating with the splashscreen.

Maybe the need for text-encoding-polyfill is unfortunate as TextEncoder is used only once in rxdb and it's the only thing that makes rxdb not compatible with native environments.

@pubkey
Copy link
Owner

pubkey commented Aug 25, 2022

I accientially merged code from #3903 which is why there is the memory storage used.
I reverted this now.

We need to use the PouchDB storage because only that contains a non-premium sqlite based adapter and has the asyncstorage as alternative.

also we need either the couchdb or the rxdb-replication running.

Using the TextEncoder for hashing reduced the hash runtime by about a third. So I do not want to remove that. But maybe we can use a workarround instead of a polyfill. Because the textencoder does the same as calling charCodeAt over an array of chars.

@pubkey
Copy link
Owner

pubkey commented Sep 13, 2022

Closing this in favor of #3903

@pubkey pubkey closed this Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments