react-native-skia icon indicating copy to clipboard operation
react-native-skia copied to clipboard

Data loss using Skia Pictures / drawPicture

Open MAVERlCK opened this issue 3 years ago • 2 comments

Description

Hello there, first thanks a lot for this incredible library 🎉

I was trying to use Pictures for its ability to duplicate pictures easily using .serialize(), Skia.Picture.MakePicture() and canvas `drawPicture()' methods. Unfortunately it seems that there's somehow a limit on how many items can be serialized after being drawn. Once that limit reached, it seems that we lose previous drawn data (maybe due to a silent error ?).

I tried to debug this issue but without any success unfortunately, so I did a little reproduction repo in order to let you check what's really happening.

Version

0.1.213

Steps to reproduce

I reproduced this issue on an iOS simulator (ios 17)

To describe what my reproduction code is doing :

  • a fake hook returns new coordinates each 100ms
  • each time a coordinates is received in the rendering component,
    • it creates a new picture which contains
      • the previous picture
      • a new Rect element based on received coordinates

Snack, code example, screenshot, or link to a repository

https://github.com/MAVERlCK/SkiaPictureCrash

MAVERlCK avatar Oct 21 '23 17:10 MAVERlCK

It appears that you are continuously/recursively drawing pictures into picture. There might be indeed a limitation on the possible nesting there. Why do you do it? I strongly suspect that there is a way to rewrite this example without needing such a method and I would love to learn more about your use-case.

Kind regards,

William

On Sat, Oct 21, 2023 at 7:35 PM Hocine Moukaideche @.***> wrote:

Description

Hello there, first thanks a lot for this incredible library 🎉

I was trying to use Pictures for its ability to duplicate pictures easily using .serialize(), Skia.Picture.MakePicture() and canvas `drawPicture()' methods. Unfortunately it seems that there's somehow a limit on how many items can be serialized after being drawn. Once that limit reached, it seems that we lose previous drawn data (maybe due to a silent error ?).

I tried to debug this issue but without any success unfortunately, so I did a little reproduction repo in order to let you check what's really happening.

Version

0.1.213

Steps to reproduce

To describe what my reproduction code is doing :

a fake hook returns new coordinates each 100ms each time a coordinates is received in the rendering component,

it creates a new picture which contains

the previous picture a new Rect element based on received coordinates

Snack, code example, screenshot, or link to a repository

https://github.com/MAVERlCK/SkiaPictureCrash

— Reply to this email directly, view it on GitHub or unsubscribe. You are receiving this email because you are subscribed to this thread.

Triage notifications on the go with GitHub Mobile for iOS or Android.

wcandillon avatar Dec 04 '23 10:12 wcandillon

I'm closing this for now because this seems to be somewhat the expected behaviour but please let me know if we need to revisit this.

wcandillon avatar Apr 04 '24 07:04 wcandillon