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

[expo-blur][Android] Add support for BlurView on Android #21744

Merged
merged 10 commits into from
Mar 29, 2023

Conversation

behenate
Copy link
Member

Why

There was no support for BlurView on android. Instead of blurring the view would just set the background color to semitransparent.

How

Using BlurView library and Modules API added blur support for Android. Default prop settings match it quite closely with the iOS version.

Test Plan

Tested on Android emulators (API 33 and 28), and a physical device (API 31). Also compared the look of the blur on android emulator to the iOS simulator.

@behenate behenate requested a review from lukmccall March 17, 2023 11:46
@behenate behenate self-assigned this Mar 17, 2023
@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Mar 17, 2023
@fobos531
Copy link
Contributor

This is a great idea if we want to support as many Android versions as possible. However, this is a 3rd party library - any thoughts on using the built-in Android API for this? https://source.android.com/docs/core/display/window-blurs The downside to the built-in API is that its only available from Android 12 while I'm sure the 3rd party package supports lower Android versions as well.

I think both using the 3rd party library and 1st party Android support has its up and downsides. Maybe we could use BlurView on Android < 12 and use the built-in support on Android >= 12, provided there is a way to achieve API parity across the two libraries and all android versions? Thoughts?

behenate and others added 2 commits March 17, 2023 12:56
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Mar 17, 2023
@behenate
Copy link
Member Author

behenate commented Mar 17, 2023

@fobos531 It seems like using the built-in API would require us to create a separate activity for blurring which is not really viable. The 3rd party library is using RenderEffect.createBlurEffect from API 31 though.

@ArtKullashi
Copy link

I'm so glad to see this pr and hope it gets merged. So long as it looks similar to the ios blur, I don't think it should matter if you use the built-in API or the library.

@behenate behenate marked this pull request as ready for review March 21, 2023 07:52
@behenate behenate requested a review from lukmccall March 21, 2023 07:53
packages/expo-blur/src/BlurView.types.ts Show resolved Hide resolved
packages/expo-blur/src/BlurView.tsx Outdated Show resolved Hide resolved
packages/expo-blur/src/BlurView.tsx Outdated Show resolved Hide resolved
@behenate behenate requested a review from lukmccall March 21, 2023 19:54
@aleqsio
Copy link
Contributor

aleqsio commented Mar 21, 2023

I hope we'll land this, using a lot of blur views in the appjs app ❤️
Curious how the performance of the android implementation looks like without platform support, hope it's fairly fast 🙏

@fobos531
Copy link
Contributor

I hope we'll land this, using a lot of blur views in the appjs app ❤️ Curious how the performance of the android implementation looks like without platform support, hope it's fairly fast 🙏

Same! It would be awesome if it can be shipped as a "post-release addition" of SDK 48, but if its not feasible and has to wait until SDK 49, completely understandable! 👍

@behenate behenate marked this pull request as draft March 23, 2023 10:18
… not updating on android. Move tint calculation to native code. Update tests.
@behenate behenate marked this pull request as ready for review March 24, 2023 08:24
@behenate behenate requested a review from lukmccall March 24, 2023 11:28
@Nodonisko
Copy link

Great job, we will use this ASAP in our app!

@@ -13,6 +13,7 @@ exports[`renders a native blur view 1`] = `
testID="blur"
>
<ViewManagerAdapter_ExpoBlurView
blurReductionFactor={4}
Copy link
Contributor

Choose a reason for hiding this comment

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

I've talked with @tsapete - we decided it will be better to rename that. Let's call it androidBlurReductionFactor instead.

Copy link
Member

Choose a reason for hiding this comment

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

Fyi: I've been convinced to keep blurReductionFactor as this is not common across our APIs to use platform names in such cases and also that this prop is not going to be used very often because the default behavior is good enough in most cases.

@behenate behenate merged commit 3075515 into main Mar 29, 2023
@behenate behenate deleted the @behenate-expo-blur-android-support branch March 29, 2023 08:51
EvanBacon pushed a commit that referenced this pull request Apr 5, 2023
# Why

There was no support for `BlurView` on android. Instead of blurring the
view would just set the background color to semitransparent.

# How

Using [BlurView](https://github.com/Dimezis/BlurView) library and
Modules API added blur support for Android. Default prop settings match
it quite closely with the iOS version.

# Test Plan

Tested on Android emulators (API 33 and 28), and a physical device (API
31). Also compared the look of the blur on android emulator to the iOS
simulator.

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@tsapeta tsapeta added the published Changes from the PR have been published to npm label Apr 17, 2023
@eeshankeni
Copy link

This update makes Android lag uncontrollably on my OnePlus 6. But on other Android devices, it seems to work fine.
Here is a recording before and after setting intensity to 0
https://imgur.com/a/DiKVmbs

@tsapeta
Copy link
Member

tsapeta commented Apr 28, 2023

@eeshankeni Can you open an issue with a minimal reproducible example? Repro would help us fix it faster 🙂

@RGarrido03
Copy link

Hi! I'm trying to use the 12.3.0 version of expo-blur because of this feature. However, when running and compiling to Android, the Expo server tells me that The native view manager required by name (ExpoBlurView) from NativeViewManagerAdapter isn't exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [ExpoLinearGradient, ExpoVideoView, ExpoBarCodeScanner, ExponentGLView, ExpoImage, ExponentCamera].

I guess this happens due to the fact that I'm using the latest stable version of Expo (i.e., the 48.0.15 one), so how can I sort this thing out? Since version 49 beta isn't still available, is there any way to compile Expo from the source? Thanks.

@tsapeta
Copy link
Member

tsapeta commented May 3, 2023

Hey @RGarrido03, could you please open a new issue instead of reporting it on the PR? We'll also need a minimal reproducible example, so we can test it out ourselves.

Generally this feature should work well with all 48.* versions, except Expo Go that we don't update in between of SDK releases. If you're using bare workflow or development builds then there should be no issue like this. In the latter case, you'll need to rebuild the app as it contains native changes. If that doesn't solve the issue, please open a new issue as I said at the beginning.

@expo expo locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet