🐛 Error handling doesn't work and crashes the app

Open
#281 11 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
react-native, typescript
Domain
mobile

Research direction

Start with the reproduction in app/example7.tsx and inspect the Rive component's onError path for the listed RNRiveErrorType cases. Run the Example 7 malformed-file scenario on iOS or Android and trace the failure. Done means each error handled by onError reports through the callback without crashing the app.

Written by the indexing model from the issue text.

Description

Description

Hi 👋

<Rive> component allows us (normally) to handle some errors (RNRiveErrorType):

  • IncorrectRiveFileUrl
  • MalformedFile
  • FileNotFound
  • IncorrectArtboardName
  • UnsupportedRuntimeVersion
  • IncorrectStateMachineName
  • IncorrectStateMachineInput

But instead of displaying a warning and/or handling error with onError, the app crashes instantly with any of the errors listed above 😕

Example

The app crash instantly with something like that:

const malformedFileUrl =
  "https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg";

const correctFileUrl =
  "https://public.rive.app/community/runtime-files/2195-4346-avatar-pack-use-case.riv";

export default function Example7() {
  const riveRef = useRef<RiveRef>(null);

  return (
      <Rive
        url={malformedFileUrl}
        // url={correctFileUrl}
        onError={(riveError: RNRiveError) => {
          switch (riveError.type) {
            case RNRiveErrorType.IncorrectRiveFileUrl: {
              console.log(`${riveError.message}`);
              return;
            }
            case RNRiveErrorType.MalformedFile: {
              console.log("Malformed File");
              return;
            }
            case RNRiveErrorType.FileNotFound: {
              console.log("File not found");
              return;
            }
            case RNRiveErrorType.IncorrectArtboardName: {
              console.log("IncorrectAnimationName");
              return;
            }
            case RNRiveErrorType.UnsupportedRuntimeVersion: {
              console.log("Runtime version unsupported");
              return;
            }
            case RNRiveErrorType.IncorrectStateMachineName: {
              console.log(`${riveError.message}`);
              return;
            }
            case RNRiveErrorType.IncorrectStateMachineInput: {
              console.log(`${riveError.message}`);
              return;
            }
            default:
              return;
          }
        }}
      />
  );
}

Repository

To reproduce, I created a rive playground: https://github.com/guval-gh/rive-playground
And the last example (Example 7) crash: https://github.com/guval-gh/rive-playground/blob/main/app/example7.tsx

Expected behavior

I expect my log to be displayed in the case of onError:

case RNRiveErrorType.MalformedFile: {
    console.log(“Malformed File”);
    return;
}

I expect that all the error cases that can be handled via onError won't cause the app to crash.

Screenshots

As soon as I try to go to the screen of the previous example, the app crashes:

https://github.com/user-attachments/assets/80479365-6d88-4dde-8e45-202f42ae766e

Device
  • (Screenrecord): iOS Simulator - iOS 18.1
  • Crash on iOS Simulator and Android Emulator

Additional context

Crash appear on:

"expo": "^52.0.11",
"react-native": "0.76.3",
"rive-react-native": "^8.2.0",

Also tested on rive-react-native versions: 8.0.0 and 8.1.0

Dominant language
TypeScript
Stars
783
Forks
81
Avg merge
3d 6h
Merged PRs (30d)
3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rive-app/rive-react-native

All issues in rive-app/rive-react-native

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.