2d-inc / Flare-Flutter

Load and get full control of your Rive files in a Flutter project using this library.
https://rive.app/
MIT License
2.55k stars 469 forks source link

error in 1.8.0 or bigger #204

Closed akilinomendez closed 4 years ago

akilinomendez commented 4 years ago

Hi, running the same flr in 1.7.3 dont have errors in the 1.8.1 i have this error:

════════ Exception caught by rendering library ═════════════════════════════════ The following StackOverflowError was thrown during paint(): Stack Overflow

The relevant error-causing widget was FlareActor lib\main.dart:46 When the exception was thrown, this was the stack

0 _TypedDoubleListMixin.setRange (dart:typed_data-patch/typed_data_patch.dart:752:3)

1 ActorArtboard.artboardAABB

package:flare_dart/actor_artboard.dart:657

2 FlutterActorLayerEffectRenderer.draw

package:flare_flutter/flare.dart:1320

3 FlutterActorLayerEffectRenderer.drawPass

package:flare_flutter/flare.dart:1526

4 FlutterActorLayerEffectRenderer.draw

package:flare_flutter/flare.dart:1363 ... The following RenderObject was being processed when the exception was fired: FlareActorRenderObject#dd552 RenderObject: FlareActorRenderObject#dd552 parentData: (can use size) constraints: BoxConstraints(w=533.3, h=320.0) size: Size(533.3, 320.0) ════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════ Stack Overflow The relevant error-causing widget was FlareActor lib\main.dart:46 ════════════════════════════════════════════════════════════════════════════════

The main code:

void main() {

runApp(MyApp()); }

class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]); SystemChrome.setEnabledSystemUIOverlays([]); return MaterialApp( debugShowCheckedModeBanner: false, title: testFlare', theme: ThemeData(primarySwatch: Colors.blue), home: MyHomePage(), ) } }

class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => new _MyHomePageState(); }

class _MyHomePageState extends State { @override Widget build(BuildContext context) { return new FlareActor("assets/ciclo_lanzarote.flr", alignment:Alignment.center, fit:BoxFit.contain, animation:"ciclo"); } }

any ideas;

Thank you.

akilinomendez commented 4 years ago

I found that the failure occurs, when I have masks in the animation

Remove this part in the flr file the app launch.
{ "name": "Node", "parent": 6806, "isActive": true, "source": 6805, "maskType": 0, "type": "mask" }

I'm waiting, in order to use the masks.

King regards.

luigi-rosso commented 4 years ago

Hi @akilinomendez, could you share the flr file and link to the file on https://rive.app if it is public? Thanks!

akilinomendez commented 4 years ago

Hi, for now remove the masks and work,

I'm working on flutter clock app and I don't want to publish anything to date, but you can do in read mode here https://rive.app/a/aki/files/flare/ciclo-lanzarote

The problem occurs when I create a mask to change the color of the clouds.

Thanks for your answer.

luigi-rosso commented 4 years ago

I haven't had a chance to investigate this further yet, but have you tried using the binary format? Is the result the same? I'm still traveling for the next two days so I may not be able to get to this until a little later.

luigi-rosso commented 4 years ago

Could you export a version with the mask applied and send the crashing exported .flr file (both binary and json please) to luigi@rive.app?

akilinomendez commented 4 years ago

Ok, I discovered the error, I really don't know if it's a bug or if I'm doing wrong.

When the shape with mask in the layer flutter don't run.

fail

Nevertheless, if the mask outside the shape run

run

I will send you the four files, but now that it works for me this way if you want you can close the issue.

Thanks for your attention

vinceMuni commented 4 years ago

I am experiencing the same issue with my animation at https://rive.app/a/Vincemoo/files/flare/hourglass-1 @luigi-rosso I already sent you an email containing my files. Please let me know if you need anything else.

luigi-rosso commented 4 years ago

@vinceMuni could you try flare_flutter: ^1.8.2 and see if that improves things?

SideNote: I noticed you are using a lot of masks, but the shapes you are clipping against are solid. Try using clips instead, the performance will be better on lower-end GPUs. Masking has to draw to a separate layer in order to then do a per pixel blend that gets expensive, especially when applied to a lot of shapes.

In general: use masks when you need per-pixel alpha/faded masking and use clips where you want hard edges to simply cut one shape from another.

vinceMuni commented 4 years ago

Hi @luigi-rosso, Thank you for your advices. As you said, with the new version flare_flutter: ^1.8.2 everything is working smoothly! I changed my animation as well, so I got no problems on running it. Thank you for your job and all the time you spend on it. I think the issue can be definitely closed.