nateshmbhat / touchable

The only flutter library to add gestures and animations to custom shapes you draw on your canvas.
https://pub.dev/packages/touchable
Mozilla Public License 2.0
233 stars 80 forks source link

Crashes when trying to use onPanUpdte to draw new points #19

Closed kumar-aakash86 closed 3 years ago

kumar-aakash86 commented 3 years ago

Hi I am trying to achieve a drawing functionality using this library. I want to draw a shape using path & then want user to draw within that area. This library have all the events to implement that but when I am trying to draw all the generated points then it crashes my app.

myCanvas.drawPath(AlphabetPaths.getAlphabetA(size), paint,
        onPanUpdate: (details) {
      points.add(details.localPosition);
      drawNewPath(myCanvas, points);
    });
drawNewPath(myCanvas, points) {
    print(points);
    points.removeWhere((value) => value == null);
    var _pointPaint = Paint()
      ..color = Colors.black
      ..strokeWidth = 5
      ..style = PaintingStyle.fill
      ..strokeCap = StrokeCap.square;
      myCanvas.drawPoints(PointMode.points, points, _pointPaint);
  }

When I am trying to draw new points using onPanUpdate it always crashing on both mobile & web. If I try to add those points directly its working fine.

I am getting following error

I/flutter ( 8546): [Offset(123.0, 469.3), Offset(123.0, 472.4)]
F/libc    ( 8546): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28 in tid 10318 (1.ui), pid 8546 (le.gesture_demo)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'OnePlus/OnePlus5/OnePlus5:10/QKQ1.191014.012/2010292059:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-03-30 13:56:54+0530
pid: 8546, tid: 10318, name: 1.ui  >>> com.example.gesture_demo <<<
uid: 11240
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28
Cause: null pointer dereference
    x0  0000000000000000  x1  000000701f108908  x2  000000701f108958  x3  0000000000000000
    x4  000000701f108960  x5  000000702153a0d0  x6  0000000000000002  x7  000000000000003c
    x8  0000000000000000  x9  0000000000000002  x10 0000000000000001  x11 0000000000000000
    x12 0000000000000005  x13 0000008000000000  x14 000a68cc29c0d93d  x15 000000701f108a10
    x16 0000007021ccb398  x17 00000071116a98b8  x18 000000701ee8a000  x19 0000000000000000
    x20 000000702153a0d0  x21 0000007021539954  x22 0000007021c70278  x23 0000007021c6e2c0
    x24 000000701030ced1  x25 000000701f030000  x26 000000700e7c3800  x27 0000007010310730
    x28 0000000000000004  x29 000000701f108a48
    sp  000000701f108900  lr  000000702153b63c  pc  000000702153a0d0
backtrace:
      #00 pc 00000000013220d0  /data/app/com.example.gesture_demo-pJ5hsmnHb2pDpOT8vlkuyA==/lib/arm64/libflutter.so (BuildId: 4f453a1bb64d1244a9dd8bd68e926b4779043b43)
      #01 pc 00000000000f6914  <anonymous:701f012000>
Lost connection to device.
Exited (sigterm)

There are no null values in the array as you can see in the first line of crash log which are the list of points. I also added code to remove if there is any null value available.

You can see that right now points only have 2 items but its still crashing.

I tried multiple things but not able to fix this. I don't have any idea why its crashing with only 2 points. Do you have any idea why this is happening or can you fix this? If you found the issue let me know. I might be able to help you with this.

Thanks

nateshmbhat commented 3 years ago

Hello, based on the logs the null pointer crash is not happening in the touchable library dart code at all. It's happening within flutter library itself probably in the flutter engine which contains the c++ code.

This definitely seems like an issue in flutter. Please file a bug report with sample code to reproduce this issue in flutter repository.

On Tue, 30 Mar, 2021, 2:18 pm Aakash Kumar, @.***> wrote:

Hi I am trying to achieve a drawing functionality using this library. I want to draw a shape using path & then want user to draw within that area. This library have all the events to implement that but when I am trying to draw all the generated points then it crashes my app.

myCanvas.drawPath(AlphabetPaths.getAlphabetA(size), paint, onPanUpdate: (details) { points.add(details.localPosition); drawNewPath(myCanvas, points); });

drawNewPath(myCanvas, points) { print(points); points.removeWhere((value) => value == null); var _pointPaint = Paint() ..color = Colors.black ..strokeWidth = 5 ..style = PaintingStyle.fill ..strokeCap = StrokeCap.square; myCanvas.drawPoints(PointMode.points, points, _pointPaint); }

When I am trying to draw new points using onPanUpdate it always crashing on both mobile & web. If I try to add those points directly its working fine.

I am getting following error

I/flutter ( 8546): [Offset(123.0, 469.3), Offset(123.0, 472.4)] F/libc ( 8546): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28 in tid 10318 (1.ui), pid 8546 (le.gesture_demo)


Build fingerprint: 'OnePlus/OnePlus5/OnePlus5:10/QKQ1.191014.012/2010292059:user/release-keys' Revision: '0' ABI: 'arm64' Timestamp: 2021-03-30 13:56:54+0530 pid: 8546, tid: 10318, name: 1.ui >>> com.example.gesture_demo <<< uid: 11240 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x28 Cause: null pointer dereference x0 0000000000000000 x1 000000701f108908 x2 000000701f108958 x3 0000000000000000 x4 000000701f108960 x5 000000702153a0d0 x6 0000000000000002 x7 000000000000003c x8 0000000000000000 x9 0000000000000002 x10 0000000000000001 x11 0000000000000000 x12 0000000000000005 x13 0000008000000000 x14 000a68cc29c0d93d x15 000000701f108a10 x16 0000007021ccb398 x17 00000071116a98b8 x18 000000701ee8a000 x19 0000000000000000 x20 000000702153a0d0 x21 0000007021539954 x22 0000007021c70278 x23 0000007021c6e2c0 x24 000000701030ced1 x25 000000701f030000 x26 000000700e7c3800 x27 0000007010310730 x28 0000000000000004 x29 000000701f108a48 sp 000000701f108900 lr 000000702153b63c pc 000000702153a0d0 backtrace:

00 pc 00000000013220d0 /data/app/com.example.gesture_demo-pJ5hsmnHb2pDpOT8vlkuyA==/lib/arm64/libflutter.so (BuildId: 4f453a1bb64d1244a9dd8bd68e926b4779043b43)

  #01 pc 00000000000f6914  <anonymous:701f012000>

Lost connection to device. Exited (sigterm)

There are no null values in the array as you can see in the first line of crash log which are the list of points. I also added code to remove if there is any null value available.

You can see that right now points only have 2 items but its still crashing.

I tried multiple things but not able to fix this. I don't have any idea why its crashing with only 2 points. Do you have any idea why this is happening or can you fix this? If you found the issue let me know. I might be able to help you with this.

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nateshmbhat/touchable/issues/19, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFRTSNVVQ4VFJCOPFFACY5LTGGF43ANCNFSM42BRPWBA .