Skip to content

[Impeller] Draw Arc with sweep angle 0 causes app to crash #137484

@feelsantiago

Description

@feelsantiago

Is there an existing issue for this?

Steps to reproduce

Use the example provided and change the progress value to 0.

Expected results

App should not crash and should behavior like skia.

Actual results

The app crashes and throws null pointer dereference.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'dart:math' as math;

extension DegToRad on num {
  num degToRad() {
    return this * (math.pi / 180.0);
  }

  num convertRadiusToSigma() {
    return this * 0.57735 + 0.5;
  }
}

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const Scaffold(
        body: Center(
          child: SizedBox(
            height: 200,
            width: 200,
            child: CustomPaint(
              painter: Arc(progress: 0),
              child: Center(child: Text('Test')),
            ),
          ),
        ),
      ),
    );
  }
}

class Arc extends CustomPainter {
  final num progress;
  const Arc({required this.progress});

  @override
  void paint(Canvas canvas, Size size) {
    final center = Offset((size.width) / 2, (size.height / 2));
    final radius = (size.height * 0.70);
    final rect = Rect.fromCircle(center: center, radius: radius);
    final paint = Paint();
    const fillColor = Color(0xFFEE0405);

    final translation = Offset(0, size.height / 3);
    canvas.translate(translation.dx, translation.dy);

    paint
      ..style = PaintingStyle.stroke
      ..strokeWidth = size.width * 0.013;

    final fillShader = SweepGradient(
        startAngle: 180.degToRad().toDouble(),
        stops: const [
          0.0,
          0.3,
          0.7,
          1
        ],
        colors: [
          fillColor.withOpacity(0),
          fillColor,
          fillColor,
          fillColor.withOpacity(0)
        ]).createShader(Rect.fromCircle(center: center, radius: radius));

    paint
      ..shader = fillShader
      ..color = fillColor
      ..maskFilter =
          MaskFilter.blur(BlurStyle.solid, 3.convertRadiusToSigma().toDouble());

    canvas.drawArc(
      rect,
      180.degToRad().toDouble(),
      // Error hapens here when this value is 0
      (180 * (progress / 100)).degToRad().toDouble(),
      false,
      paint,
    );
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

Screenshots or Video

Screenshots / Video demonstration

Skia

skia.mp4

Impeller

impeller.mp4

Logs

Logs Those logs only show when running Android.
Performing hot reload...                                                
Reloaded 1 of 689 libraries in 301ms (compile: 59 ms, reload: 93 ms, reassemble: 78 ms).
F/libc    ( 8728): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 8761 (1.raster), pid 8728 (le.impeller_bug)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/r8qxx/r8q:13/TP1A.220624.014/G780GXXS7EWI3:user/release-keys'
Revision: '6'
ABI: 'arm64'
Processor: '4'
Timestamp: 2023-10-28 15:53:37.070621916-0300
Process uptime: 20s
Cmdline: com.example.impeller_bug
pid: 8728, tid: 8761, name: 1.raster  >>> com.example.impeller_bug <<<
uid: 10500
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000000
Cause: null pointer dereference
    x0  0000000000000000  x1  0000006fe39a3480  x2  0000006fe39a3480  x3  b40000703efe4f58
    x4  0000000000000438  x5  00000000000008e2  x6  0000000000000000  x7  0000006fe39a3df8
    x8  0000006fe39a3388  x9  0000006fe6482600  x10 b40000703eefb8e0  x11 0000000000000000
    x12 000000703f3f6830  x13 0000000000147de8  x14 0000000000147da8  x15 0000007115e9c8a2
    x16 0000007115f78a70  x17 0000007115f66f2c  x18 0000006fe0ce6000  x19 0000006fe39a351c
    x20 b40000703efe4f18  x21 b40000703efe4f58  x22 0000006fe39a3480  x23 b40000703efe4f40
    x24 0000006fe39a3be8  x25 b40000703f117960  x26 b40000703f117b40  x27 0000006fe39a39b0
    x28 0000006fe39a49e0  x29 0000006fe39a4b00
    lr  0000006fe647e35c  sp  0000006fe39a3300  pc  0000006fe6482604  pst 0000000080001000
backtrace:
      #00 pc 00000000019db604  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #01 pc 00000000019d7358  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #02 pc 00000000019d9440  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #03 pc 00000000019d9510  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #04 pc 00000000019cd804  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #05 pc 00000000019e8020  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #06 pc 00000000019e75d0  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #07 pc 00000000019e6cc8  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #08 pc 00000000019f909c  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #09 pc 0000000001b1ff3c  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #10 pc 00000000019ac7c8  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #11 pc 00000000019ac748  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #12 pc 0000000001a43b48  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #13 pc 0000000001a428a4  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #14 pc 0000000001a430bc  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #15 pc 0000000001a441c4  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #16 pc 0000000001a42c94  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #17 pc 0000000001a42a08  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #18 pc 0000000001a4faec  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #19 pc 00000000016a722c  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #20 pc 00000000016ac8d8  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #21 pc 0000000000018028  /system/lib64/libutils.so (android::Looper::pollInner(int)+1064) (BuildId: 97f353c1a350efeb766e1e852854da85)
      #22 pc 0000000000017b9c  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+116) (BuildId: 97f353c1a350efeb766e1e852854da85)
      #23 pc 0000000000018598  /system/lib64/libandroid.so (ALooper_pollOnce+104) (BuildId: a5f6911a1c3c5eaaabc875c3a07fb701)
      #24 pc 00000000016ac860  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #25 pc 00000000016a7188  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #26 pc 00000000016aadd8  /data/app/~~TGITVT2rqYJBHE7D86KHlQ==/com.example.impeller_bug-Mt6pDNvhfyvjpq_dYw8TpA==/lib/arm64/libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e
10efeac15)
      #27 pc 00000000000f5298  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 1bcad8bca80d38bceb9089f70d394e33)
      #28 pc 000000000008ebdc  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 1bcad8bca80d38bceb9089f70d394e33)
Lost connection to device.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.13.9, on macOS 14.0 23A344 darwin-arm64, locale pt-BR)
    • Flutter version 3.13.9 on channel stable at /Users/filipesantiago/Library/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d211f42860 (3 days ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/filipesantiago/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2021.2)
    • Android Studio at /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 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.83.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.74.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 14.0 23A344 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 118.0.5993.117

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

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: fatal crashCrashes that terminate the processe: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions