rive-app / rive-flutter

Flutter runtime for Rive
https://rive.app
MIT License
1.21k stars 191 forks source link

example program throws error with sdk: '>=2.12.0 <3.0.0': Unhandled Exception: Unsupported operation: Unsupported property key 30. A new runtime is likely necessary to play this file. #96

Closed wterrill closed 3 years ago

wterrill commented 3 years ago

I just updated an app to null safety and was unable to load assets that had been working before. I narrowed it down to this package by doing the following:

  1. run 'flutter create rivetest'
  2. enable null safety with 'dart migrate --apply-changes'
  3. add rive: ^0.7.7 as a dependency in pubspec.yaml
  4. add rive asset declaration in pubspec.yaml as well as in the folder structure with a known, working .riv file
  5. copy and paste the code from the example page (with null-safety modifications) as below: i``` mport 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:rive/rive.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); }

class _MyAppState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { return const MaterialApp( home: MyHomePage(), ); } }

class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key);

@override _MyHomePageState createState() => _MyHomePageState(); }

class _MyHomePageState extends State { void _togglePlay() { setState(() => _controller!.isActive = !_controller!.isActive); }

/// Tracks if the animation is playing by whether controller is running. bool get isPlaying => _controller?.isActive ?? false;

Artboard? _riveArtboard; RiveAnimationController? _controller; @override void initState() { super.initState();

// Load the animation file from the bundle, note that you could also
// download this. The RiveFile just expects a list of bytes.
rootBundle.load('assets/rive/testRive.riv').then(
  (data) async {
    // Load the RiveFile from the binary data.
    final file = RiveFile.import(data);
    // The artboard is the root of the animation and gets drawn in the
    // Rive widget.
    final artboard = file.mainArtboard;
    // Add a controller to play back a known animation on the main/default
    // artboard.We store a reference to it so we can toggle playback.
    artboard.addController(_controller = SimpleAnimation('idle'));
    setState(() => _riveArtboard = artboard);
  },
);

}

@override Widget build(BuildContext context) { return Scaffold( body: Center( child: _riveArtboard == null ? const SizedBox() : Rive(artboard: _riveArtboard!), ), floatingActionButton: FloatingActionButton( onPressed: _togglePlay, tooltip: isPlaying ? 'Pause' : 'Play', child: Icon( isPlaying ? Icons.pause : Icons.play_arrow, ), ), ); } }


6. when run... the following error and stacktrace appear:

> [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Unsupported operation: Unsupported property key 30. A new runtime is likely necessary to play this file.
> #0      _skipProperty
> #1      _readRuntimeObject
> #2      new RiveFile._
> #3      new RiveFile.import
> #4      _MyHomePageState.initState.<anonymous closure>
> #5      _MyHomePageState.initState.<anonymous closure>
> #6      _rootRunUnary (dart:async/zone.dart:1362:47)
> #7      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
> #8      _FutureListener.handleValue (dart:async/future_impl.dart:152:18)
> #9      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)
> #10     Future._propagateToListeners (dart:async/future_impl.dart:733:32)
> #11     Future._completeWithValue (dart:async/future_impl.dart:539:5)
> #12     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:254:13)
> #13     PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart)
> <asynchronous suspension>

here is my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.3 20E232 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.56.0)
[✓] Connected device (3 available)

• No issues found!

This happens for builds with flutter web, MacOs and ios.
If I changed the riveTest.riv file to another known, working, .riv file, the 'property key' number changes. (in this case, it's 30... but I've seen a variety of other numbers that seem to always be below 100)
luigi-rosso commented 3 years ago

Thanks for reporting! Can you share the .riv file? You can email it to luigi@rive.app if it's a file you prefer to not share publicly.

wterrill commented 3 years ago

I can't attached the file (I get an 'we don't support that file type' error in github when I try) but I downloaded one from this repo:

and modified the code above to change: 'assets/rive/testRive.riv' to 'assets/rive/off_road_car_0_6.riv' after saving that file in the assets/rive folder (the download button is on the right side of the page above)

and got this error:

[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Unsupported operation: Unsupported property key 1241. A new runtime is likely necessary to play this file.

0 _skipProperty

package:rive/src/rive_file.dart:63

1 _readRuntimeObject

package:rive/src/rive_file.dart:49

2 new RiveFile._

package:rive/src/rive_file.dart:103

3 new RiveFile.import

package:rive/src/rive_file.dart:217

4 _MyHomePageState.initState.

package:rivetest/main.dart:47

5 _MyHomePageState.initState.

package:rivetest/main.dart:45

6 _rootRunUnary (dart:async/zone.dart:1362:47)

7 _CustomZone.runUnary (dart:async/zone.dart:1265:19)

8 _FutureListener.handleValue (dart:async/future_impl.dart:152:18)

9 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:704:45)

10 Future._propagateToListeners (dart:async/future_impl.dart:733:32)

11 Future._completeWithValue (dart:async/future_impl.da<…>

wterrill commented 3 years ago

FWIW, I upgraded to rive:0.7.8 and saw the same issue. Can anyone else reproduce this? I'm still uncertain if it's my environment.

luigi-rosso commented 3 years ago

I haven't reproduced it with any of our files. You can zip the file and post it here. That'd be really helpful for tracking this down.

wterrill commented 3 years ago

Sure. I put a link above to the following file: off_road_car_0_6.riv.zip

luigi-rosso commented 3 years ago

Oh sorry, I totally missed that. Looking now!

wterrill commented 3 years ago

I just installed the latest version of flutter (channel stable) on an old mac I had, and got the exact same error. My steps:

  1. flutter create rivetest
  2. cd rivetest
  3. dart migrate --apply-changes
  4. copied code from my first post
  5. modified pubspec.yaml to add rive: ^0.7.8
  6. modified pubspec.yaml to add the assets/rive folder to the project.
  7. Downloaded the .riv file from this page and placed it in the assets/rive folder.
  8. ran the program as MacOs, iOS and Chrome

Upon running, I get the same error: [VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Unsupported operation: Unsupported property key 1241. A new runtime is likely necessary to play this file.

and, BTW... thanks for the help!

luigi-rosso commented 3 years ago

np! This is a file exported for our 0.6 runtimes. I'm surprised it's not throwing an error when trying to open the file. You can still drag and drop this into the editor and export a 0.7 compatible file (or use a 0.6.x runtime).

Still doing some testing, we should probably throw a more helpful error (and earlier).

luigi-rosso commented 3 years ago

Screen Shot 2021-05-08 at 10 33 32 AM

wterrill commented 3 years ago

That was the issue. thank you very much! (heck, I didn't realize that there was a difference in downloaded animations... thanks for the help!)