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

fix: prevent crashes during onuncaughterror #141

Merged
merged 2 commits into from
Feb 9, 2022

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Jan 25, 2022

This PR aims to address some unwanted crashes that would happen during the OnUncaughtError handler.

The first relates to how the AppPackageJson file was being read to fetch the discardUncaughtJsExceptions flag. The NSJSONSerialization would produce a NSDictionary that would get autoreleased. On subsequent calls to OnUncaughtError, the AppPackageJson pointer would be cleared causing a bad access.

To address this, I alloc and init a new NSDictionary from the serialization so that this dictionary will not get released between calls to OnUncaughtError. I'm not super familiar with Objective-C or how this runtime is setup, so I don't know if there is a point where we should manually release this dictionary. Please let me know if this should be handled.

Second, I ran into an unhelpful stack trace when trying to test the error events I setup and eventually realized that my event handlers were also causing a javascript exception, but since we were already in the OnUncaughtError method, the tns::Assert would be false and quit the app. I addressed this by using TryCatch and logging the caught error so developers have visibility on if their error event handlers are also causing an error.

This PR will most likely close #126 and possibly is related to some crashes other users have reported.

@cla-bot
Copy link

cla-bot bot commented Jan 25, 2022

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Adam Bird.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot added the cla: yes label Jan 25, 2022
@NathanWalker NathanWalker changed the base branch from master to release/8-2 February 9, 2022 17:20
@NathanWalker NathanWalker merged commit 6a9184e into NativeScript:release/8-2 Feb 9, 2022
@NathanWalker
Copy link
Contributor

We will release this in the next 8.2.x alpha shortly thank you for this.

@Archez Archez deleted the fix/crashHandler branch February 9, 2022 19:57
@NathanWalker
Copy link
Contributor

In 8.2.0-alpha.6 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

discardUncaughtJsExceptions: true not working with new runtime
2 participants