Skip to content

[web] CanvasKit Path.combine(difference) replaces result fill rule and fills the hole #195968

Description

@jamesblasco

Steps to reproduce

  1. Create a Flutter project with the standard flutter_test SDK dev dependency.
  2. Save the code below as test/path_combine_test.dart.
  3. Run flutter test test/path_combine_test.dart: it passes.
  4. Run flutter test --platform chrome test/path_combine_test.dart: it fails.

The reproduction uses the default CanvasKit web renderer. No third-party packages or custom shapes are needed.

Expected results

Subtracting a 196×196 rectangle from a surrounding 200×200 rectangle produces a 2-pixel ring. The result contains (1, 1), but does not contain (100, 100). Both native and web should agree.

Actual results

Native returns center=false and passes. Chrome returns center=true and fails. Drawing the result with a fill paints the entire outer rectangle, including the supposed hole.

This also affects custom ShapeBorder painters that draw an outer-minus-inner path: when the border is painted over a child, any positive border width can cover the whole child rather than just its outline.

Code sample

import 'dart:ui';
import 'package:flutter_test/flutter_test.dart';

void main() {
  test('difference of nested rectangles preserves the hole', () {
    final outer = Path()..addRect(const Rect.fromLTWH(0, 0, 200, 200));
    final inner = Path()..addRect(const Rect.fromLTWH(2, 2, 196, 196));
    final ring = Path.combine(PathOperation.difference, outer, inner);

    print('fillType=${ring.fillType}, '
        'center=${ring.contains(const Offset(100, 100))}, '
        'border=${ring.contains(const Offset(1, 1))}');

    expect(ring.contains(const Offset(1, 1)), isTrue);
    expect(ring.contains(const Offset(100, 100)), isFalse);
  });
}

Screenshots or Video

The minimal example uses Path.contains so that the incorrect geometry is reproducible without relying on a screenshot.

Logs

Native:

fillType=PathFillType.evenOdd, center=false, border=true
All tests passed!

Chrome:

fillType=PathFillType.nonZero, center=true, border=true
Expected: false
  Actual: <true>
Some tests failed.

Suspected cause

In CkPathBuilder.combine on Flutter 3.47.8, CanvasKit computes the operation, but the result is then wrapped using the first input's fill type:

final combined = CkPathBuilder.fromSkPath(combinedSkPath, path1.fillType);

The fromSkPath factory explicitly applies that fill type to the copied SkPathBuilder:

skPathBuilder.setFillType(toSkFillType(fillType));

As an additional isolation check, calling CanvasKit.Path.MakeFromOp(outer, inner, Difference) directly with nested rectangles produces an even-odd path with contains(100, 100) == false. Copying that result into a PathBuilder and setting its fill type to Winding, as the wrapper does, changes contains(100, 100) to true.

The result's own fill rule appears to need preservation instead of replacement with the first operand's rule. The same two lines are present in the current default-branch source inspected for this report; the runtime reproduction concerns the 3.47.8 implementation. This has not been bisected, and an engine patch has not been built or tested.

Flutter Doctor output

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.47.4, on macOS 27.2 26B123 darwin-arm64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 27.0)
[✓] Chrome - develop for the web

Activity

  1. added
    in triage
    on Nov 4, 2026
  2. suryaKommana2662 commented on Nov 4, 2026

    @suryaKommana2662
    Contributor

    @jamesblasco Thanks for the detailed report. I was able to reproduce the issue locally using the provided test case. The results match the reported behavior. Routing to team-web for further investigation.

    Logs:

    suryakommana@SuryaKommanas-MacBook-Pro default_app % flutter test --platform chrome test/widget_test.dart
    00:01 +0: difference of nested rectangles preserves the hole                                                                                                          
    fillType=PathFillType.nonZero, center=true, border=true
    00:01 +0 -1: difference of nested rectangles preserves the hole [E]                                                                                                   
      Expected: false
        Actual: <true>
      
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 274:3       throw_
      package:matcher                                                                   expect$
      package:flutter_test/src/widget_tester.dart 473:18                                expect$
      widget_test.dart 15:5                                                             <fn>
      package:test_api                                                                  <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 618:19               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 643:23               <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 589:19               <fn>
      dart-sdk/lib/async/zone_root.dart 48:47                                           _rootRunUnary
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 816:35                                               runUnary
      dart-sdk/lib/async/future_impl.dart 222:18                                        handleValue
      dart-sdk/lib/async/future_impl.dart 948:44                                        handleValueCallback
      dart-sdk/lib/async/future_impl.dart 977:13                                        _propagateToListeners
      dart-sdk/lib/async/future_impl.dart 720:5                                         [_completeWithValue]
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 499:7                complete
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 566:12               _asyncReturn
      package:test_api                                                                  <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 618:19               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 643:23               <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 589:19               <fn>
      dart-sdk/lib/async/zone_root.dart 48:47                                           _rootRunUnary
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 816:35                                               runUnary
      dart-sdk/lib/async/future_impl.dart 222:18                                        handleValue
      dart-sdk/lib/async/future_impl.dart 948:44                                        handleValueCallback
      dart-sdk/lib/async/future_impl.dart 977:13                                        _propagateToListeners
      dart-sdk/lib/async/future_impl.dart 543:9                                         <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone.dart 702:7                                                runGuarded
      dart-sdk/lib/async/zone.dart 743:23                                               <fn>
      dart-sdk/lib/async/schedule_microtask.dart 40:34                                  _microtaskLoop
      dart-sdk/lib/async/schedule_microtask.dart 49:5                                   _startMicrotaskLoop
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 183:69               <fn>
      ===== asynchronous gap ===========================
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 849:35                                               registerBinaryCallback
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 642:23               _wrapJsFunctionForAsync
      package:test_api                                                                  <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone_api.dart 164:63                                           _runZoned
      dart-sdk/lib/async/zone_api.dart 91:10                                            runZoned
      package:test_api                                                                  <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 618:19               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 643:23               <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 589:19               <fn>
      dart-sdk/lib/async/zone_root.dart 48:47                                           _rootRunUnary
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 816:35                                               runUnary
      dart-sdk/lib/async/future_impl.dart 222:18                                        handleValue
      dart-sdk/lib/async/future_impl.dart 948:44                                        handleValueCallback
      dart-sdk/lib/async/future_impl.dart 977:13                                        _propagateToListeners
      dart-sdk/lib/async/future_impl.dart 711:7                                         [_complete]
      dart-sdk/lib/async/future.dart 265:13                                             <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/async/zone_root.dart 27:47                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone.dart 702:7                                                runGuarded
      dart-sdk/lib/async/zone.dart 743:23                                               <fn>
      package:stack_trace                                                               <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone.dart 726:23                                               <fn>
      dart-sdk/lib/_internal/js_dev_runtime/private/isolate_helper.dart 47:11           internalCallback
      ===== asynchronous gap ===========================
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 849:35                                               registerBinaryCallback
      dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 642:23               _wrapJsFunctionForAsync
      package:test_api                                                                  <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone_api.dart 164:63                                           _runZoned
      dart-sdk/lib/async/zone_api.dart 91:10                                            runZoned
      package:stack_trace                                                               <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone_api.dart 164:63                                           _runZoned
      dart-sdk/lib/async/zone_api.dart 91:10                                            runZoned
      package:test_api                                                                  [_onRun]
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      package:test_api                                                                  <fn>
      dart-sdk/lib/async/zone_root.dart 35:13                                           _rootRun
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 810:35                                               run
      dart-sdk/lib/async/zone_api.dart 164:63                                           _runZoned
      dart-sdk/lib/async/zone_api.dart 91:10                                            runZoned
      package:test_api                                                                  <fn>
      dart-sdk/lib/async/zone_root.dart 48:47                                           _rootRunUnary
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 816:35                                               runUnary
      dart-sdk/lib/async/zone.dart 710:7                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone_root.dart 56:13                                           _rootRunUnary
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 816:35                                               runUnary
      dart-sdk/lib/async/zone.dart 710:7                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/async/stream_controller.dart 898:5                                   add
      package:stream_channel                                                            <fn>
      dart-sdk/lib/async/zone.dart 963:9                                                runUnaryGuarded
      dart-sdk/lib/internal/async_cast.dart 95:5                                        [_onData]
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 963:9                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 963:9                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/async/stream_controller.dart 898:5                                   add
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 963:9                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/operations.dart 118:77  tear
      dart-sdk/lib/async/zone.dart 963:9                                                runUnaryGuarded
      dart-sdk/lib/async/stream_impl.dart 381:5                                         [_sendData]
      dart-sdk/lib/async/stream_impl.dart 312:7                                         [_add]
      dart-sdk/lib/async/stream_controller.dart 798:5                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 832:7                                   [_sendData]
      dart-sdk/lib/async/stream_controller.dart 663:7                                   [_add]
      dart-sdk/lib/async/stream_controller.dart 618:5                                   add
      dart-sdk/lib/async/stream_controller.dart 898:5                                   add
      package:stream_channel                                                            add
      package:flutter_test/src/_test_selector_web.dart 77:15                            <fn>
      dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 218:27    _callDartFunctionFast1
      dart-sdk/lib/_internal/js_dev_runtime/patch/js_allow_interop_patch.dart 78:15     ret
      
    
    To run this test again: /Users/suryakommana/develop/flutter/bin/cache/dart-sdk/bin/dart test test/widget_test.dart -p chrome --plain-name 'difference of nested rectangles preserves the hole'
    00:01 +0 -1: Some tests failed.   

    Flutter Doctor Output

    [✓] Flutter (Channel stable, 3.47.7, on macOS 27.0 26A428 darwin-arm64, locale en-IN) [1,297ms]
        • Flutter version 3.47.7 on channel stable at /Users/suryakommana/develop/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision abaf9c5237 (4 weeks ago), 2026-10-08 09:51:21 -0700
        • Engine revision deb287481e
        • Dart version 3.13.5
        • DevTools version 2.60.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets,
          enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [2.1s]
        • Android SDK at /Users/suryakommana/Library/Android/sdk
        • Emulator version 37.2.13.0 (build_id 16740729) (CL:N/A)
        • Platform android-37.0, build-tools 36.0.0
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 25.0.2+-15348964-b329.117)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 27.2) [2.1s]
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 27B52
        • CocoaPods version 1.17.0
    
    [✓] Chrome - develop for the web [3ms]
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Connected device (3 available) [5.9s]
        • iPhone 18 Pro (mobile) • D80F2104-E911-4251-BEDD-E67D9B7EBF58 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-27-0 (simulator)
        • macOS (desktop)        • macos                                • darwin-arm64   • macOS 27.0 26A428 darwin-arm64
        • Chrome (web)           • chrome                               • web-javascript • Google Chrome 156.0.8078.80
    
    [✓] Network resources [980ms]
        • All expected network resources are available.
    
    • No issues found!
  3. added
    a: tests
    platform-web
    has reproducible steps
    team-web
    and removed
    in triage
    on Nov 4, 2026
  4. added
    triaged-web
    on Nov 4, 2026
  5. removed
    triaged-web
    on Nov 4, 2026
  6. flutter-triage-bot commented on Nov 4, 2026

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-web label.

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

Metadata

Metadata

Assignees

Labels

a: testshas reproducible stepsplatform-webteam-web

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions