Skip to content

feat: iOS filter blur #52028

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

intergalacticspacehighway
Copy link
Contributor

@intergalacticspacehighway intergalacticspacehighway commented Jun 15, 2025

Summary:

This PR is controversial since it uses CAFilter API to achieve the desired filter: blur() effect. But I thought to open the PR, to keep it open for discussion. Currently, this API is the simplest and most performant way to achieve the effect.

Changelog:

[IOS] [ADDED] - Blur filter

Test Plan:

Run RNTester blur example, which is enabled in the PR. Set the hotdog image's overflow to visible or else blur will clip to bounds for image.

Aside:

I have seen some competing frameworks using this property in the wild. So I wanted to open the discussion if we can do the same in RN. CIFilter option does not seem feasible for generic views apart from images. Maybe Metal can help? I haven't done much digging there.

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 15, 2025
@javache
Copy link
Member

javache commented Jun 16, 2025

CAFilter is a private API, by shipping this in React Native you'd put every app at risk of app store rejection.

@intergalacticspacehighway
Copy link
Contributor Author

intergalacticspacehighway commented Jun 16, 2025

@javache Sorry, I should've been more explicit. It is being used by lynx here so I assumed appstore won't be an issue. But I agree about the risk aspect of rejection and a potential breaking change. Still I opened the PR for discussion, if we can find some alternative.

@NickGerleman
Copy link
Contributor

NickGerleman commented Jun 17, 2025

CAFilter is something we wanted to use, but we really don’t want to add it as an API that folks could rely on, then be forced to take it back later if Apple doesn’t approve. Given their history, that’s not unlikely.

A solution I’ve been curious about though, is that SwiftUI exposes a public filters API that uses this under the hood.

There are libraries that have sandwiched SwiftUI views inside of RN’s UIKit hierarchy too. https://github.com/andrew-levy/swiftui-react-native/blob/master/ios/VStack/VStackExpoView.swift

I imagine it might be easier to compose a “FilterView” or the like, which sandwiches in the SwiftUI view, but I’ve been curious about this as a mechanism to implement the normal CSS filters API, with some clever view hierarchy management.

@intergalacticspacehighway intergalacticspacehighway marked this pull request as draft June 19, 2025 17:38
@intergalacticspacehighway
Copy link
Contributor Author

@NickGerleman i haven't done much digging on the SwiftUI approach yet, looks interesting, will try some stuff. I also found a library that accesses CAFilter via a public filters property here, still has a breaking change potential, but would love to know your thoughts. I added a commit based on that approach. Totally get it if still feels uncomfortable (will explore SwiftUI approach)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants