Skip to content

iOS: CustomPainter MaskFilter.blur and saveLayer + ImageFilter.blur draw hard-edged; drawShadow draws nothing #122

Backlog

Description

@tayormi

Select your plan

Standard - priority support

Confirmations

  • I searched the existing issues and this is not a duplicate.

Framework or plugin?

Framework

Plugin name and version

No response

Platform

iOS

Public reproduction repo

https://github.com/tayormi/dn-issue-repros

Steps to reproduce

In a CustomPainter on iOS, every blur draws with a sharp edge, and drawShadow draws nothing:

  • Paint.maskFilter = MaskFilter.blur(BlurStyle.normal, sigma) on drawCircle, drawRRect and drawPath draws the shape with a sharp edge, the same as a paint with no mask filter.
  • saveLayer(bounds, Paint(imageFilter: ImageFilter.blur(sigmaX: s, sigmaY: s))), then a draw and restore(), also draws a sharp shape.
  • drawShadow(path, color, elevation, false) draws nothing. It doesn't throw either.

A widget BoxShadow(blurRadius: 16) on the same screen is soft, so the device can draw blurs. A larger sigma (20) doesn't change anything.

The API says all three work, and the docs list no gaps for them. In lib/src/widgets/custom_paint.dart, ImageFilter.blur is documented as "Gaussian blur applied to the saved layer", saveLayer as applying paint "to the composited result", and Canvas.drawShadow as "Draw a shadow for the given [path]". MaskFilter.blur and BlurStyle exist so that MaskFilter.blur(BlurStyle.normal, 4) "compiles as written". The same file marks other gaps clearly, e.g. a shader on a stroked paint "is silently ignored … gradient strokes are not supported", and "Unsupported (silently ignored, documented for parity)" for the gradient matrix4 and focal. Blur and shadows have no such note. The only hint is CustomPaint's doc, which names "the supported op subset (shapes, paths, simple gradients, clipping, transforms)". Also, BinaryCanvasRecorder's op codes (_CanvasOp, save 0x01 … drawImageRect 0x14) have no drawShadow op at all.

Setup, all in lib/repros/21_canvas_blur.dart: each row is a CustomPaint(size: Size(width, 90), painter: ...) that draws a red shape. Two controls: a Container with BoxShadow(blurRadius: 16), and a drawCircle with no blur. Then MaskFilter.blur at sigma 8 on a circle, a rounded rect and a triangle path; saveLayer with ImageFilter.blur at sigma 8 around a drawCircle; drawShadow(triangle, black, 8, false) in a try/catch that prints on error, under a white triangle with a grey outline; then the maskFilter circle and the saveLayer circle again at sigma 20.

  1. Clone the reproduction repo linked above and run dn run on an iOS simulator (seen on the iPhone Air, iOS 26.5 simulator).
  2. Tap 21 Canvas blur and drawShadow and scroll through the rows.
  3. Observe: the BoxShadow control is soft. Every maskFilter shape and both saveLayer circles have the same sharp edge as the no-blur circle, at sigma 8 and sigma 20. The drawShadow row shows only the outlined triangle, and the device log has no repro 21: drawShadow threw line.

Expected: soft blurred shapes and a shadow under the triangle, as the API docs describe (and as Flutter draws them).

Please either support these on the native backend (Core Graphics has CGContextSetShadowWithColor, and Core Image or a layer filter for a Gaussian blur; Android has BlurMaskFilter and RenderEffect), or document them as "unsupported, silently ignored", the way stroked shaders are. Even better, give a signal the analyzer can show, such as @Deprecated, so we don't find out from screenshots.

In a real app we wanted a soft shadow under ticket shapes drawn with drawPath. Our workaround stacks 48 faint outlines of the path, each one a little bigger.

Screenshots or video

maskFilter rows saveLayer, drawShadow, sigma 20
maskFilter rows saveLayer, drawShadow and sigma 20 rows

Close-up: the BoxShadow control (soft), the circle with no blur, and the circle with MaskFilter.blur(BlurStyle.normal, 8) (just as sharp):

Close-up

Logs

No response

dn doctor output

[!] DartNative (Channel stable, 1.10.0, on macOS 26.6 25G72 darwin-arm64, locale en-CA) [499ms]
    • DartNative version 1.10.0 on channel stable at ~/zero
    ! Warning: `flutter` on your path resolves to ~/Flutter/flutter/bin/flutter, which is not inside your current DartNative SDK checkout at ~/zero. Consider adding ~/zero/bin to the front of your path.
    ! Warning: `dart` on your path resolves to ~/Flutter/flutter/bin/dart, which is not inside your current DartNative SDK checkout at ~/zero. Consider adding ~/zero/bin to the front of your path.
    • Downloaded from https://cdn.dartnative.com; "dn upgrade" moves it to the newest release, "dn releases" lists the others
    • Framework revision bdfb466e6d1 (4 days ago), 2026-11-24 15:36:11 +0100
    • Framework edition b2263be6a0167213
    • Engine revision de099f669f
    • Dart version 3.12.0 (build 3.12.0-192.0.dev)
    • DevTools version 2.55.0
    • DartNative download mirror https://cdn.dartnative.com
    • Feature flags: enable-android, enable-ios, cli-animations, enable-native-assets, enable-lldb-debugging, enable-uiscene-migration
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[!] Xcode - develop for iOS and macOS (Xcode 27.2) [938ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 27B52
    ! iOS 27.2 Simulator not installed; this may be necessary for iOS and macOS development.
      To download and install the platform, open Xcode, select Xcode > Settings > Components,
      and click the GET button for the required platform.

      For more information, please visit:
        https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
    • CocoaPods version 1.16.2

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions