Repository: flutter
Issue: [iOS] [Impeller] Flutter 3.27 `BoxShadow.spreadRadius` draws black box artefact around widget on physical iOS device, not on simulator
Labels: c: regression,platform-ios,engine,has reproducible steps,P1,e: impeller,team-engine,triaged-engine,found in release: 3.27,found in release: 3.29

### Steps to reproduce

1. Use Flutter 3.27 (tested on 3.27.2 and 3.27.3) or master
2. Run the code sample on a **physical** iOS device (tested on iOS 18.2.1). I can **not** reproduce this on an iOS simulator running iOS 18.2.
3. Observe the black box artefacts around the image widgets.
5. Commenting out `spreadRadius` removes black box artefacts.
6. Running the same code on Android produces no such artefacts.
7. Running the same code on iOS (physical device and simulator) using `--no-enable-impeller` produces no such artefacts.
8. Running the same code sample on Flutter 3.24.5 produces no such artefacts on iOS (physical device and simulator)### Expected results

No black box artefacts around images.

### Actual results

Black box artefacts around images.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  static const String title = 'BoxShadow Impeller iOS Glitch';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: title,
      home: const ExamplePage(title: title),
    );
  }
}

class ExamplePage extends StatelessWidget {
  const ExamplePage({
    super.key,
    required this.title,
  });

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: ListView.separated(
        padding: const EdgeInsets.all(24),
        itemCount: 5,
        separatorBuilder: (_, __) => const SizedBox(height: 16),
        itemBuilder: (_, int index) =>
            ExampleRow(imageUrl: 'https://picsum.photos/80/60?image=$index'),
      ),
    );
  }
}

class ExampleRow extends StatelessWidget {
  const ExampleRow({
    super.key,
    required this.imageUrl,
  });

  final String imageUrl;

  @override
  Widget build(BuildContext context) {
    return ClipRRect(
      borderRadius: BorderRadius.circular(4),
      clipBehavior: Clip.antiAlias,
      child: Container(
        padding: const EdgeInsets.all(16),
        decoration: BoxDecoration(
          color: const Color.fromRGBO(0, 0, 0, 0.4),
        ),
        child: Align(
          alignment: Alignment.center,
          child: DecoratedBox(
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(16),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.1),
                  offset: Offset(0, 8),
                  blurRadius: 32,
                  spreadRadius: -40, // Broken in Flutter 3.27
                ),
                BoxShadow(
                  color: Colors.grey.withOpacity(0.1),
                  offset: Offset(0, 2),
                  blurRadius: 8,
                  spreadRadius: -1, // Broken in Flutter 3.27
                ),
              ],
            ),
            child: SizedBox(
              width: 80,
              height: 60,
              child: ClipRRect(
                borderRadius: BorderRadius.circular(4),
                child: Image.network(imageUrl, fit: BoxFit.cover),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
```

You can also find an example project exhibiting the bug here https://github.com/techouse/flutter_boxshadow_ios_impeller_glitch_example

</details>


### Screenshots or Video

| Flutter 3.24.5 ✅ | Flutter 3.27.3 ❌ | Flutter master ❌ |
|--|--|--|
| ![Image](https://github.com/user-attachments/assets/eb7a8144-0307-4aa9-bb94-787963c66ce9) | ![Image](https://github.com/user-attachments/assets/06d04241-119c-461e-9671-f1c1154cf475) | ![Image](https://github.com/user-attachments/assets/f70f1c85-076d-425d-b9ae-d6818ed4725b) |


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-arm64, locale en-GB)
    • Flutter version 3.27.3 on channel stable at /Users/techouse/fvm/versions/3.27.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (2 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/techouse/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/techouse/Library/Android/sdk
    • Java binary at: /Users/techouse/Applications/Android Studio Koala Feature Drop 2024.1.2 Patch 1.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/techouse/Applications/Android Studio Koala Feature Drop 2024.1.2 Patch 1.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

[✓] Android Studio (version 2024.2)
    • Android Studio at /Users/techouse/Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.2.1)
    • IntelliJ at /Users/techouse/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 83.0.4
    • Dart plugin version 243.23654.44

[✓] Connected device (4 available)
    • techouse’s iPhone (mobile)      • XXXXXXXX-XXXXXXXXXXXXXXXX • ios            • iOS 18.2.1 22C161
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 131.0.6778.267

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>