rive-app / rive-flutter

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

Error: LateInitializationError: Field '_makeYogaStyle' has not been initialized. #389

Closed naidu199 closed 4 months ago

naidu199 commented 4 months ago

rootBundle.load(animationURL).then( (data) { final file = RiveFile.import(data); // error in this line

Encountering a LateInitializationError with the message "Field '_makeYogaStyle' has not been initialized."

The error message suggests an internal issue within the Rive library: "_makeYogaStyle" hasn't been initialized. This likely indicates a bug within the library's layout engine.

dubug message: Error: LateInitializationError: Field '_makeYogaStyle' has not been initialized. dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 297:3 throw packages/rive_common/src/layout_engine_wasm.dart 7:20 get _makeYogaStyle packages/rive_common/src/layout_engine_wasm.dart 527:36 makeLayoutStyle packages/rive_common/layout_engine.dart 129:12 make packages/rive/src/rive_core/layout_component.dart 28:48 new packages/rive/src/generated/artboard_base.dart 123:7 new packages/rive/src/rive_core/shapes/shape_paint_container.dart 77:1 new packages/rive/src/rive_core/artboard.dart 681:17 new packages/rive/src/runtime_artboard.dart 33:21 new packages/rive/src/rive_file.dart 53:20 _readRuntimeObject packages/rive/src/rive_file.dart 176:22 __ packages/rive/src/rive_file.dart 347:21 import packages/animated_login/login_screen.dart 42:31 dart-sdk/lib/async/zone.dart 1661:54 runUnary dart-sdk/lib/async/future_impl.dart 162:18 handleValue dart-sdk/lib/async/future_impl.dart 838:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 867:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 643:5 [_completeWithValue] dart-sdk/lib/async/future_impl.dart 713:7 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7

NashIlli commented 4 months ago

+1

vance-liu commented 4 months ago

+1 This problem occurs only on the web.

Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (4 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1
UntitledApps commented 4 months ago

+1 This problem occurs only on the web.

Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (4 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1

Nope it also happens to me on iOS.

UntitledApps commented 4 months ago

1+

UntitledApps commented 4 months ago

Getting the same issue on my iOS Emulator

naidu199 commented 4 months ago

+1 This problem occurs only on the web.

Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (4 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1

No, it also happened on Android

vance-liu commented 4 months ago

+1 This problem occurs only on the web.

Flutter 3.19.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 54e66469a9 (4 weeks ago) • 2024-04-17 13:08:03 -0700
Engine • revision c4cd48e186
Tools • Dart 3.3.4 • DevTools 2.31.1

No, it also happened on Android

I use rive 0.13.4, compiled and tested web, ios, macos, and android, only web has this problem.

UntitledApps commented 4 months ago

I fixed the problem by running flutter clean

kuldeepsm commented 4 months ago

Facing the same issue, LateInitializationError: Field '_makeYogaStyle' has not been initialized this is a bug within a library. any possible solution here?

vance-liu commented 4 months ago

For me, this problem occurs on the web using the following code.

final bytes = await rootBundle.load(riveAsset!.path);
_file = RiveFile.import(bytes);

Change to the following code to resolve this issue.

_file = await RiveFile.asset(riveAsset!.path);

Maybe

RiveFile.import
RiveFile._

did not call the initialization function causing the problem.

kuldeepsm commented 4 months ago

For me, this problem occurs on the web using the following code.

final bytes = await rootBundle.load(riveAsset!.path);
_file = RiveFile.import(bytes);

Change to the following code to resolve this issue.

_file = await RiveFile.asset(riveAsset!.path);

Maybe

RiveFile.import
RiveFile._

did not call the initialization function causing the problem.

thanks @vance-liu, after changing this line, it's working fine for me

naidu199 commented 4 months ago

For me, this problem occurs on the web using the following code.

final bytes = await rootBundle.load(riveAsset!.path);
_file = RiveFile.import(bytes);

Change to the following code to resolve this issue.

_file = await RiveFile.asset(riveAsset!.path);

Maybe

RiveFile.import
RiveFile._

did not call the initialization function causing the problem.

thank you @vance-liu now it's working