Skip to content

Android: a blur of 0.5 or less in a filter list drops every filter before it, so [{grayscale: 1}, {blur: 0}] draws the view unfiltered #60341

Backlog

Description

@YevheniiKotyrlo

Description

On Android 12 and later, a filter list that holds a blur is drawn as a chain of RenderEffects, and a blur of 0.5 or less removes every filter written before it. FilterHelper.createBlurEffect returns null when sigma <= 0.5 (L119-L122), and parseFilters makes that result the chain (L63), so the effects chained before the blur are dropped and the functions after it start a new chain. The early return came in with #43721 as a fix for a crash on small values.

[{grayscale: 1}, {blur: 0}] draws the view unfiltered, and [{invert: 1}, {blur: 0.5}, {sepia: 1}] draws it with sepia(1) alone. A blur that draws nothing leaves the image as it is in CSS (Filter Effects 1), so the functions before it still apply.

The threshold compares sigma as given, in dp, before sigmaToRadius converts it to pixels and answers 0 for half a pixel or less (L406-L413).

Steps to reproduce

  1. Clone the reproducer and write [{"grayscale":1},{"blur":0}] to ReproducerApp/filter.json.
  2. yarn install in ReproducerApp, and run it on a device with Android 12 or later (yarn android).
  3. The white screen shows one 200 × 200 box with backgroundColor: 'rgb(255, 0, 0)' and that filter.

Expected: the box is rgb(54, 54, 54), grayscale(1) of the red, as in a browser.
Seen: the box is rgb(255, 0, 0), unfiltered.

bash reproduce-android.sh '[{"grayscale":1},{"blur":0}]' at the reproducer's root does the same on the device adb is attached to: it writes the list, builds and installs the release app, reads the colour at the box's centre from adb exec-out screencap, and exits 1 when the box shows the list without the functions before its blur.

React Native Version

0.88.1, and 0.90.0-nightly-20261127-7a2d1d257

Affected Platforms

Runtime - Android

Output of npx @react-native-community/cli info

System:
  OS: Windows 11 10.0.26300
  CPU: "(32) x64 AMD Ryzen 9 9950X3D 16-Core Processor          "
  Memory: 94.48 GB / 255.67 GB
Binaries:
  Node:
    version: 26.12.1
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.22
    path: C:\Users\[…]\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 12.2.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.26100.0
IDEs:
  Android Studio: AI-262.9437.185.2621.16467767
  Visual Studio: Not Found
Languages:
  Java:
    version: 17.0.20.1
    path: C:\Program Files\Microsoft\jdk-17.0.20.101-hotspot\bin\javac.EXE
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli":
    installed: 20.2.0
    wanted: 20.2.0
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.88.1
    wanted: 0.88.1
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

bash reproduce-android.sh '[{"grayscale":1},{"blur":0}]' on a Galaxy S23:

[…]
react-native 0.88.1, release build, SM-S911B on Android 14 (API 34)
filter: [{"grayscale":1},{"blur":0}] on a rgb(255, 0, 0) box over rgb(255, 255, 255)
in the order written, as CSS draws it: rgb(54, 54, 54)
without the functions before blur(0): rgb(255, 0, 0)
the box's centre on the screen: rgb(255, 0, 0)
the box draws the list without the functions before blur(0)

bash reproduce-android.sh '[{"invert":1},{"blur":0.5},{"sepia":1}]':

[…]
react-native 0.88.1, release build, SM-S911B on Android 14 (API 34)
filter: [{"invert":1},{"blur":0.5},{"sepia":1}] on a rgb(255, 0, 0) box over rgb(255, 255, 255)
in the order written, as CSS draws it: rgb(244, 218, 170)
without the functions before blur(0.5): rgb(100, 89, 69)
the box's centre on the screen: rgb(100, 89, 69)
the box draws the list without the functions before blur(0.5)

The reproducer's nightly branch, on 0.90.0-nightly-20261127-7a2d1d257, prints the same colours for both lists:

[…]
react-native 0.90.0-nightly-20261127-7a2d1d257, release build, SM-S911B on Android 14 (API 34)
filter: [{"grayscale":1},{"blur":0}] on a rgb(255, 0, 0) box over rgb(255, 255, 255)
in the order written, as CSS draws it: rgb(54, 54, 54)
without the functions before blur(0): rgb(255, 0, 0)
the box's centre on the screen: rgb(255, 0, 0)
the box draws the list without the functions before blur(0)

MANDATORY Reproducer

https://github.com/YevheniiKotyrlo/react-native-android-filter-colours

Screenshots and Videos

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions