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

Upgrade to Expo SDK 45 #5

Merged
merged 8 commits into from
May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 31 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ A preview video (**click the image**):

> **⚠️ Caution!** Many features used in this demo are in early, experimental stage and they're not ready for production. Use on your own risk.

- Runs on [Expo SDK 43](https://blog.expo.dev/expo-sdk-43-aa9b3c7d5541), takes advantage of the new [Expo Modules architecture](https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc).
- Uses [Expo custom managed workflow](https://docs.expo.dev/workflow/customizing/) - a _prebuilding_ is used to generate native directories. All native changes (even these unusual) and patches are covered with config plugins and yarn `postinstall` script.
- Runs on [Expo SDK 45](https://blog.expo.dev/expo-sdk-45-f4e332954a68), takes advantage of the new [Expo Modules architecture](https://blog.expo.dev/whats-new-in-expo-modules-infrastructure-7a7cdda81ebc).
- Uses [Expo custom managed workflow](https://docs.expo.dev/workflow/customizing/) - a _prebuilding_ is used to generate native directories. All native changes (even these unusual) and patches are covered with config plugins.
- Uses [Expo Dev Client](https://docs.expo.dev/clients/introduction/), react-navigation, ui-kitten
- Bluetooth communication using [react-native-ble-plx](https://github.com/dotintent/react-native-ble-plx) with [config plugin](https://github.com/expo/config-plugins/tree/master/packages/react-native-ble-plx)
- Bluetooth communication using [react-native-ble-plx](https://github.com/dotintent/react-native-ble-plx) with [config plugin](https://github.com/expo/config-plugins/tree/main/packages/react-native-ble-plx)
- Color picker using Expo GL, made from [this tutorial from William Candillon](https://www.youtube.com/watch?v=bAZhVl9YvB4), but rewritten to [Reanimated v2](https://github.com/software-mansion/react-native-reanimated)
- Music Picker is an expo-module written using [Swift/Kotlin "Sweet" API](https://blog.expo.dev/a-peek-into-the-upcoming-sweet-expo-module-api-6de6b9aca492).
- JSI real-time Audio streaming, _inspired by [this PR](https://github.com/expo/expo/pull/13516), thank you Marc!_

Now it is included in upstream `expo-av@10.2.0` but yet for iOS only. It'a super-secret hidden feature of SDK 44.
Now it is included in upstream `expo-av@10.2.0` (Expo SDK 45) so a custom native module is no longer needed!

- Player controls stolen from NCL (internal Expo rn-tester equivalent).
- FFT is calculated in the JS thread. The spectrum bin heights are written to `SharedValue`s and animated with Reanimated 2.
Expand All @@ -39,27 +39,46 @@ Just to start the bundler (without rebuilding client): run `yarn start`.

## Known issues

Most of them are caused by limited time of mine, and also by some libraries, which depend on Expo, but have not yet been updated to support recently-released Expo SDK 43.
Most of them are caused by limited time of mine, and also by some libraries, which depend on Expo, but have not yet been updated to support latest Expo features.

- ~~iOS JSI Audio is not working on Hermes yet. I'm working on it.~~ Should be working now, lmk if it's not.
- Frequency bin labels are wrong 🤷. Eventually I needed to display them in log scale and I am too lazy to think about how to recalculate everything properly.
- Modifying the `sound.setOnAudioSampleReceived` callback and the Reanimated 2 stuff requires at least picking the song again to reload properly, sometimes whole app restart is needed.
- May not work on emulator. _The JSI Audio should work, but as far as I remember, the music picker does not open. And, of course, Bluetooth cannot work on simulator._
- ~~Not yet works for Android~~ There's basic experimental Android support, but with issues:
- GL View crashes
- JSI Audio crashes after few seconds
- GL View sometimes crashes
- JSI Audio might crash after a few seconds
- ...

### Applied patches

See the the `plugins` section of [`app.json`](./app.json) to see how the patches are applied:

- patch-package for `webgltexture-loader-expo@1.0.0`, a dependency of `gl-react-expo` - it has not yet been updated to use `expo-modules-core` in favor of `@unimodules/core`.
- ~~The [`custom_native_modules`](./custom_native_modules) directory needs to be added to autolinking paths in `Podfile`. A config plugin takes care of that.~~
> It appears that it can be configured in `package.json` as `expo.autolinking.searchPaths`. It's not needed anyway, look at the next point:
- ~~new `expo-modules-autolinking` requires modules to be specified in `package.json` dependencies. I don't want to copy my custom native modules to `node_modules` they are deleted after being copied there by yarn.~~

Patched `expo-modules-autolinking@0.5.1` to apply changes from [this PR](https://github.com/expo/expo/pull/15415) until it's published. Now custom native modules dir can be specified in `package.json`.

- `expo-cli` built-in plugins sets the `Push Notifications` capability even when `expo-notifications` are not installed and I see no way to disable it. Another plugin was written to delete that entitlement.
- MusicPicker module: iOS requires another `Info.plist` value about `Media Library usage permission` - a config plugin takes care of that

### No-longer-needed patches and workarounds 🎉

I started this project in Expo SDK 42 times. So much changed since then and with each release, less and less patches and workarounds were needed:

- Linking custom native modules:

- ~~The [`custom_native_modules`](./custom_native_modules) directory needs to be added to autolinking paths in `Podfile`. A config plugin takes care of that.~~
> It appears that it can be configured in `package.json` as `expo.autolinking.searchPaths`. It's not needed anyway, look at the next point:
- ~~new `expo-modules-autolinking` requires modules to be specified in `package.json` dependencies. I don't want to copy my custom native modules to `node_modules` they are deleted after being copied there by yarn.~~
- ~~Patched `expo-modules-autolinking@0.5.1` to apply changes from [this PR](https://github.com/expo/expo/pull/15415) until it's published. Now custom native modules dir can be specified in `package.json`.~~ Finally, this PR is published in upstream `expo-modules-autolinking`.

- ~~Replaced `expo-av` with my custom `expo-av-jsi` native module to support JSI Audio~~

> ~~The JSI Audio streaming is now included in upstream `expo-av@10.2.0` but yet for iOS only. It'a super-secret hidden feature of SDK 44.~~

In SDK 45 both platforms are now supported by Expo AV. 🎉

- ~~patch-package for `expo-gl` and related libraries - needed, because of migration from `@unimodules/core` to `expo-modules-core`~~
- ~~by default, expo modules are built with `xcframework` if available, but that does not work for patched `expo-gl`, so its `xcframework` is deleted force build from source.~~
- ~~`expo-gl` installs wrong `expo-modules-core` dependency in its own `node_modules` - it is deleted, the global `node_modules` one is correct.~~
- ~~The `AppDelegate.m` is being broken by `expo-dev-client` config plugin, wrote another config plugin to copy the patched file.~~
- ~~patch-package for `react-native-ble-plx` and [Podfile config plugin](./patches/fix-bluetooth.plugin.js), because of [this issue](https://github.com/dotintent/react-native-ble-plx/issues/899).~~
- There was a `postinstall.js` script to perform some of the patches above (like file copy/delete). Fortunately it is no longer needed. Yay! 🎉
1 change: 1 addition & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"supportsTablet": false
},
"android": {
"jsEngine": "jsc",
"package": "com.barthap.expomegademo",
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
Expand Down
2 changes: 0 additions & 2 deletions custom_native_modules/expo-av/.eslintrc.js

This file was deleted.

11 changes: 0 additions & 11 deletions custom_native_modules/expo-av/.npmignore

This file was deleted.

195 changes: 0 additions & 195 deletions custom_native_modules/expo-av/CHANGELOG.md

This file was deleted.