RangeError trying to read binary .flr file
jonas-zebari opened this issue · 6 comments
flare_flutter version: ^1.5.4
exception name: RangeError (byteOffset): Invalid value: Not in range 0..132, inclusive: 133
execption stack trace:
#0 _ByteDataView.getUint16 (dart:typed_data-patch/typed_data_patch.dart:4209:7)
#1 BinaryReader.readUint16Array (package:flare_dart/binary_reader.dart:66:22)
#2 ActorImage.read (package:flare_dart/actor_image.dart:152:32)
#3 ActorArtboard.readComponentsBlock (package:flare_dart/actor_artboard.dart:372:34)
#4 ActorArtboard.read (package:flare_dart/actor_artboard.dart:325:11)
#5 Actor.readArtboardsBlock (package:flare_dart/actor.dart:165:22)
#6 Actor.load (package:flare_dart/actor.dart:137:11)
<asynchronous suspension>
#7 FlutterActor.loadFromByteData (package:flare_flutter/flare.dart:673:17)
<asynchronous suspension>
#8 _IsolateConfiguration.apply (package:flutter/src/foundation/_isolates_io.dart:77:16)
#9 _spawn.<anonymous closure> (package:flutter/src/foundation/_isolates_io.dart:84:45)
<asynchronous suspension>
#10 Timeline.timeSync (dart:developer/timeline.dart:161:22)
#11 _spawn (package:flutter/src/foundation/_isolates_io.dart:82:18)
<asynchronous suspension>
#12 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:304:17)
#13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
exception occurs in function: static Future<FlutterActor> loadFromByeData(ByteData data)
-> await actor.load(data, null);
I was not having this issue until I re-exported and attempted to load my animation from the Rive editor yesterday.
sample flutter usage:
return SizedBox(
height: 150,
child: FlareActor(
'assets/animations/Multiple animation test.flr',
animation: 'idle',
),
);
example file:
Multiple animation test.zip
I cannot share a more complex example animation on GitHub but I can email it if necessary.
Hi @jonas-zebari, I think this is likely a version issue, could you try updating to 1.8.1 in your pubspec and see if that makes a difference?
Having very similar issues using version 1.8.1
:
E/flutter ( 1752): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: RangeError (index): Invalid value: Not in range 0..13, inclusive: 14
E/flutter ( 1752): #0 List.[] (dart:core-patch/array.dart:15:52)
E/flutter ( 1752): #1 ComponentAnimation.apply
package:flare_dart/animation/actor_animation.dart:257
E/flutter ( 1752): #2 ActorAnimation.apply
package:flare_dart/animation/actor_animation.dart:411
E/flutter ( 1752): #3 FlareActorRenderObject.advance
package:flare_flutter/flare_actor.dart:357
E/flutter ( 1752): #4 FlareActorRenderObject._instanceArtboard
package:flare_flutter/flare_actor.dart:291
E/flutter ( 1752): #5 FlareActorRenderObject.coldLoad
package:flare_flutter/flare_actor.dart:322
E/flutter ( 1752): <asynchronous suspension>
E/flutter ( 1752): #6 FlareRenderBox.load
package:flare_flutter/flare_render_box.dart:272
E/flutter ( 1752): #7 FlareActorRenderObject.filename=
package:flare_flutter/flare_actor.dart:263
E/flutter ( 1752): #8 FlareActor.updateRenderObject
package:flare_flutter/flare_actor.dart:101
The error occurs when I try to cycle between these 10 flare animations but only when I either update the animation file or the animation using setState
or reload using hot reload. When I change the values and then make a hot restart, everything is working fine.
I use it like this:
return FlareActor(
fileName,
fit: BoxFit.contain,
alignment: Alignment.center,
// animation is either 'in' our 'out'
animation: animation,
);
Thanks, that helped me repro! Try flare_flutter: ^1.8.2
@luigi-rosso I changed my flare_flutter version to ^1.8.2
and ran packages get
and got this error while running on Flutter 1.7.8+hotfix.4:
RangeError (byteOffset): Invalid value: Not in range 0..132, inclusive: 133
#0 _ByteDataView.getUint16 (dart:typed_data-patch/typed_data_patch.dart:4209:7)
#1 BinaryReader.readUint16Array (package:flare_dart/binary_reader.dart:66:22)
#2 ActorImage.read (package:flare_dart/actor_image.dart:152:32)
#3 ActorArtboard.readComponentsBlock (package:flare_dart/actor_artboard.dart:372:34)
#4 ActorArtboard.read (package:flare_dart/actor_artboard.dart:325:11)
#5 Actor.readArtboardsBlock (package:flare_dart/actor.dart:165:22)
#6 Actor.load (package:flare_dart/actor.dart:137:11)
<asynchronous suspension>
#7 FlutterActor.loadFromByteData (package:flare_flutter/flare.dart:657:17)
<asynchronous suspension>
#8 _IsolateConfiguration.apply (package:flutter/src/foundation/_isolates_io.dart:77:16)
#9 _spawn.<anonymous closure> (package:flutter/src/foundation/_isolates_io.dart:84:45)
<asynchronous suspension>
#10 Timeline.timeSync (dart:developer/timeline.dart:161:22)
#11 _spawn (package:flutter/src/foundation/_isolates_io.dart:82:18)
<asynchronous suspension>
#12 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:304:17)
#13 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)
This time, the debugger stopped execution on the class AssetBundleContext
in the flare.dart
file. After getting that, I ran both packages get
and upgrade
and got this message as a compiler error instead:
Compiler message:
file:///C:/dev/flutter_purposeful/.pub-cache/hosted/pub.dartlang.org/flare_flutter-1.8.2/lib/flare.dart:1331:18: Error: The setter 'imageFilter' isn't defined for the class 'Paint'.
- 'Paint' is from 'dart:ui'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'imageFilter'.
layerPaint.imageFilter = _blurFilter(baseBlurX, baseBlurY);
^^^^^^^^^^^
file:///C:/dev/flutter_purposeful/.pub-cache/hosted/pub.dartlang.org/flare_flutter-1.8.2/lib/flare.dart:1347:13: Error: The setter 'imageFilter' isn't defined for the class 'Paint'.
- 'Paint' is from 'dart:ui'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'imageFilter'.
..imageFilter = _blurFilter(
^^^^^^^^^^^
file:///C:/dev/flutter_purposeful/.pub-cache/hosted/pub.dartlang.org/flare_flutter-1.8.2/lib/flare.dart:1391:13: Error: The setter 'imageFilter' isn't defined for the class 'Paint'.
- 'Paint' is from 'dart:ui'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'imageFilter'.
..imageFilter = _blurFilter(
^^^^^^^^^^^
For your information, I am running flutter version v1.7.8+hotfix.4. Is compatibility for flare_flutter intended for that version of Flutter? After upgrading to 1.12 stable the issue is fixed using ^1.8.2 of flare_flutter.
issue_205
Testing Flare Issue 205
Flutter Doctor
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.15.1 19B2093, locale en-US)
• Flutter version 1.12.13+hotfix.6 at /usr/local/Caskroom/flutter/1.2.1/flutter
• Framework revision 18cd7a3601 (4 weeks ago), 2019-12-11 06:35:39 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
Flare Version
flare_flutter: ^1.8.3
Testing
[✓] - Web
[✓] - Android
[✓] - iOS
Conclusion
import 'package:flare_flutter/flare_actor.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flare Issue Test',
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
home: FlareIssueExample(
title: "Flare Issue Test",
filename: 'assets/animations/test.flr',
animation: 'idle',
),
);
}
}
class FlareIssueExample extends StatelessWidget {
final String title;
final String filename;
final String animation;
const FlareIssueExample({
Key key,
@required this.title,
@required this.filename,
@required this.animation,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: FlareActor(
filename,
animation: animation,
),
);
}
}