Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):
CLI: 6.1.0
Cross-platform modules: 6.1.0
iOS Runtime: 6.1.0
Describe the bug
If there is an exception raised in the native code there is a chance that exception not to be caught if using try/catch or if discardUncaughtJsExceptions is enabled.
Add the following code in the app/main-view-model.jsonTap handler:
for (var i = 0; i < 20; i++) {
try {
MyClass.alloc().initThrowing();
} catch (ex) {
console.log(ex);
}
}
this will call 20 times the initThrowing initializer which raises an exception and when executing the app on a device tapping on the button crashes the application. The reason to make 20 calls is that the issue is sporadic and it might not happen with the first call.
Expected behavior
The application shouldn't crash because the exception is caught and the reason should be output in the console 20 times.
Additional context
The issue is valid only on real devices, as there's a known issue in libffi causing the application to crash when an exception is thrown on Simulators (#1044).
Environment Provide version numbers for the following components (information can be retrieved by running
tns info
in your project folder or by inspecting thepackage.json
of the project):Describe the bug If there is an exception raised in the native code there is a chance that exception not to be caught if using try/catch or if discardUncaughtJsExceptions is enabled.
To Reproduce
tns create myApp --template https://github.com/rosen-vladimirov/appNativeCode/tarball/master
app/App_Resources/iOS/src
folder and edit change the content of the following files to:@interface MyClass : NSObject
@end
Add the following code in the
app/main-view-model.js
onTap handler:this will call 20 times the initThrowing initializer which raises an exception and when executing the app on a device tapping on the button crashes the application. The reason to make 20 calls is that the issue is sporadic and it might not happen with the first call.
Expected behavior The application shouldn't crash because the exception is caught and the reason should be output in the console 20 times.
Additional context The issue is valid only on real devices, as there's a known issue in libffi causing the application to crash when an exception is thrown on Simulators (#1044).