airbnb / lottie-web

Render After Effects animations natively on Web, Android and iOS, and React Native. http://airbnb.io/lottie/
MIT License
30.34k stars 2.87k forks source link

String: TypeError: null is not an object (evaluating 'S.onComplete') #3102

Open vorderpneu opened 1 month ago

vorderpneu commented 1 month ago

We use lottie-web in an Ionic app with Angular and ngrx-lottie to display an animation. For some time now, we have been seeing the following error in our error logs:

String: TypeError: null is not an object (evaluating 'S.onComplete')
    postMessage@webpack:///node_modules/lottie-web/build/player/esm/lottie_light.min.js:424:28
    We@webpack:///node_modules/zone.js/fesm2015/zone.js:755:44
    runTask@webpack:///node_modules/zone.js/fesm2015/zone.js:173:57
    invokeTask@webpack:///node_modules/zone.js/fesm2015/zone.js:483:41
    O@webpack:///node_modules/zone.js/fesm2015/zone.js:1631:24
    N@webpack:///node_modules/zone.js/fesm2015/zone.js:1674:43

The error occurs here: https://github.com/airbnb/lottie-web/blob/0d658b34c40d4e81eafdccbf698815346454a899/player/js/utils/DataManager.js#L619

What is the reason that process can be null, and what would be the best way to handle this error properly?

Only iPhones and MacBooks are affected. Unfortunately, we have not been able to reproduce it on our own devices.

Browsers: Mobile Safari UI/WKWebView Apple Mail 605.1

OS Versions: iOS 15.6 iOS 15.7 iOS 15.8 iOS 16.3 iOS 16.7 iOS 17.5 Mac OS X 10.15

neehhaa06 commented 1 month ago

Hello @vorderpneu

if (S && typeof S.onComplete === 'function') {
    S.onComplete(data.payload);
} else {
    console.error('S is null or onComplete is not defined');
}
vorderpneu commented 3 weeks ago

@neehhaa06 Yes, i already tried those two suggestions, but the error is still handled by the zone.js globalCallback error and that's why the angular app still doesn't know about those errors. Yes, i could override window.onerror to handle the error, but i want to avoid that.

My idea is to have an ErrorEvent similar to e.g. BMRenderFrameErrorEvent so that I can handle the Error in the Angular app