Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Rive initialization crash: init -> rive_text_ffi not found #432

Open
julianfalcionelli opened this issue Nov 14, 2024 · 11 comments
Open
Labels
bug Something isn't working

Comments

@julianfalcionelli
Copy link

julianfalcionelli commented Nov 14, 2024

Description

On iOS my rive animations are failing on initialization.

flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Invalid argument(s): Failed to lookup symbol 'init': dlsym(RTLD_DEFAULT, init): symbol not found
flutter: 
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
#1      init (package:rive_common/src/rive_text_ffi.dart:497:16)
#2      init (package:rive_common/src/rive_text_ffi.dart)
#3      initFont (package:rive_common/src/rive_text_ffi.dart:814:3)
#4      Font.initialize (package:rive_common/rive_text.dart:463:7)
#5      RiveFile.initialize (package:rive/src/rive_file.dart:392:33)
#6      RiveFile._initTextAndImport (package:rive/src/rive_file.dart:414:13)
#7      RiveFile.asset (package:rive/src/rive_file.dart:444:12)
<asynchronous suspension>
#8      RiveAnimationState._configure (package:rive/src/widgets/rive_animation.dart:212:11)
<asynchronous suspension>
flutter: ----------------------------------------------------

On Android this is working as expected.

Rive version

rive: ^0.13.16

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.1.2 23B92 darwin-x64, locale en-AR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.93.1)
[✓] Connected device (4 available)
    ! Error: Browsing on the local area network for Julian’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

Rive File

get_started.riv.zip

Code

....

SizedBox(
            height: 400,
            child: RiveAnimation.asset(
              'assets/animations/rive/get_started.riv',
              artboard: 'Artboard',
              onInit: _onRiveInit,
            ),
          ),
....

  void _onRiveInit(Artboard artboard) {
    final controller =
        StateMachineController.fromArtboard(artboard, 'State Machine 1', onStateChange: (stateMachine, state) {
      LogHelper.d('State: $stateMachine -> $state');
      if (state == 'ExitState') {
        context.read<InitialBloc>().add(const InitialEvent.onGetStartedClicked());
      }
      if (state == 'Exit') {
        setState(() {
          _accessAccountOpacity = 0.0;
        });
      }
      if (state == 'KidsBlink') {
        setState(() {
          _accessAccountOpacity = 1.0;
        });
      }
    });
    if (controller == null) {
      LogHelper.e('State machine not found');
      return;
    }
    artboard.addController(controller);
    _controller = controller;
  }

@julianfalcionelli julianfalcionelli added the bug Something isn't working label Nov 14, 2024
@HayesGordon
Copy link
Contributor

Hi @julianfalcionelli, is this failing for you locally?

  • Which version of Flutter are you using?
  • What device is this reproducing on?

Can you try running flutter clean and rebuilding.

You can also try initializing Rive earlier in your app lifecycle. For example, at the start of main:

void main() {
  /// Initialize Rive's text, audio, and layout engines.
  /// This will automatically be called the first time a RiveFile is loaded if
  /// it has not been initialized. And does not need to be called.
  ///
  /// However, calling it early here makes the first
  /// visible Rive graphic load faster.
  unawaited(RiveFile.initialize());

...
  }

@julianfalcionelli
Copy link
Author

julianfalcionelli commented Nov 16, 2024

Hi @HayesGordon , thanks for your reply.

My Flutter version is:

Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2663184aa7 (9 weeks ago) • 2024-09-11 16:27:48 -0500
Engine • revision 36335019a8
Tools • Dart 3.5.3 • DevTools 2.37.3

We can reproduce this in all the iOS devices we have (I can get you the list of models and iOS versions next week since I have to contact QA), for me I am testing on an iPhone SE and emulator (iPhone 15 Pro - iOS 17).

I tried by cleaning everything and rebuilding (flutter clean).

I also tried calling the RiveFile.initialize() as you said but I got the same error when calling that function:

flutter: Invalid argument(s): Failed to lookup symbol 'init': dlsym(RTLD_DEFAULT, init): symbol not found
flutter: 
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
#1      init (package:rive_common/src/rive_text_ffi.dart:497:16)
#2      init (package:rive_common/src/rive_text_ffi.dart)
#3      initFont (package:rive_common/src/rive_text_ffi.dart:814:3)
#4      Font.initialize (package:rive_common/rive_text.dart:463:7)
#5      RiveFile.initialize (package:rive/src/rive_file.dart:392:33)
#6      LoadDependenciesGraphWidget.setupDependenciesGraph (package:earthrangers/ui/app/app.dart:190:20)
<asynchronous suspension>

Just got a replay from QA, the iOS devices they are using are:

  • iPhone 7: iOS 15
  • iPad pro 12.9" 3rd gen: iOS 18
  • iPad 6th gen iOS 17.5.1

@dimnocode
Copy link

dimnocode commented Nov 20, 2024

Hi,
Same issue here

Description

Simply calling RiveAnimation.asset('assets/animations/loading.riv')

No animation displayed and the following error appears in the logs.

Flutter clean and rebuild didn't help.

Works fine on Android

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'init': dlsym(RTLD_DEFAULT, init): symbol not found
#0      DynamicLibrary.lookup (dart:ffi-patch/ffi_dynamic_library_patch.dart:33:70)
#1      init (package:rive_common/src/rive_text_ffi.dart:497:16)
#2      init (package:rive_common/src/rive_text_ffi.dart)
#3      initFont (package:rive_common/src/rive_text_ffi.dart:814:3)
#4      Font.initialize (package:rive_common/rive_text.dart:463:7)
#5      RiveFile.initialize (package:rive/src/rive_file.dart:392:33)
#6      RiveFile._initTextAndImport (package:rive/src/rive_file.dart:414:13)
#7      RiveFile.asset (package:rive/src/rive_file.dart:444:12)
<asynchronous suspension>
#8      RiveAnimationState._configure (package:rive/src/widgets/rive_animation.dart:221:11)

Rive version

0.13.17

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.5, on macOS 14.7 23H124 darwin-x64, locale fr-BE)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] Connected device (4 available)
[✓] Network resources

Tested devices

Iphone SE 2020 ios 16.6.1
Emulator iphone 16 Plus ios 18.0

@HayesGordon
Copy link
Contributor

We've not been able to reproduce this issue, and I'm trying to isolate the cause.

Are you potentially overriding the rive_common package in your pubspec to be a particular version?

It'll be incredibly helpful if you can provide a small example project that reproduces this that we can run. And if you can provide info on the following:

  • Does this reproduce in a new project for you?
  • Does it only reproduce for release builds, or can you verify this error locally?
  • Did this break after a certain version of Rive Flutter, or are you adding Rive for the first time?

I see there is a similar issue on the Dart repository, can you experiment with this suggestion to see if it works for you: dart-lang/native#897 (comment)

@julianfalcionelli
Copy link
Author

Hi @HayesGordon,

I am using the latest rive: ^0.13.20 package, I am not overriding any rive_common package (on Android is working fine, so I don't think it could be related to that).

  • I haven't tried a new project yet.
  • This is happening on Release and Debug builds.
  • I am adding Rive for the first time.

I also found that thread you mentioned there and tried changing that from XCode but didn't work.

I am now updating XCode to the latest version and try again.

@Kal-Elx
Copy link

Kal-Elx commented Jan 7, 2025

Hi, this problem has recently surfaced in our app as well and we can reproduce it on all iOS devices in release, TestFlight and debug builds.

We are using

  • flutter: 3.27.1
  • xcode 16.2
  • rive: 0.13.20

I've tried to call RiveFile.initialize() during app initialization which makes the error appear when that code is called instead of when a rive animation is built.

I also tried to change Strip Style from "All Symbols" to "Non-Global Symbols" according to dart-lang/native#897 (comment) but no difference.

@Kal-Elx
Copy link

Kal-Elx commented Jan 7, 2025

@HayesGordon I tried to create a small example project to reproduce the issue but unfortunately it works then which explains why you can't reproduce it. This means that the problem most likely lies with bigger/older projects or is caused by some other dependency.

Let me know if there is anything I can do to help you debug this further.

@Kal-Elx
Copy link

Kal-Elx commented Jan 7, 2025

We bisected our history and found the commit that caused the issue. It configured CocoaPods to use static frameworks instead of dynamic ones.

To reproduce:

  • Create a new flutter project
  • Add rive as a dependency
  • Open ios/Podfile and then replace use_frameworks! with use_frameworks! :linkage => :static
  • Initialize rive by e.g.
import 'package:rive/rive.dart';

void main() {
  unawaited(RiveFile.initialize());
  runApp(const MyApp());
}

This will lead to the error Unhandled Exception: Invalid argument(s): Failed to lookup symbol 'init': dlsym(RTLD_DEFAULT, init): symbol not found.

@julianfalcionelli @dimnocode Can this be what you did as well and reverting it would fix your issue?

@julianfalcionelli
Copy link
Author

julianfalcionelli commented Jan 10, 2025

@Kal-Elx, thank you for following this. Your comment was very useful. Since the project I am working on is five years old, testing like that is a bit complicated.

I removed this use_frameworks! :linkage => :static and after that I was getting error "include of non-modular header inside framework module 'firebase_core.FLTFirebasePlugin'", but I was able to fix that by changing the following Setting in the iOS Project:

Xcode => Runner => Build Settings: Search for "Allow Non-modular Includes In Framework Modules" to "yes"

and now is working as expected.

cc: @HayesGordon

@dimnocode
Copy link

Hi @Kal-Elx,

It was indeed the issue for my case too.

Thank you very much all

@Tom3652
Copy link

Tom3652 commented Jan 26, 2025

the problem is that i need use_frameworks! :linkage => :static for google mobile ads...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants