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

Why "unhandled exceptions" on android tracked in coroutine? #304

Closed
cNoNim opened this issue Aug 23, 2019 · 4 comments
Closed

Why "unhandled exceptions" on android tracked in coroutine? #304

cNoNim opened this issue Aug 23, 2019 · 4 comments
Labels

Comments

@cNoNim
Copy link

cNoNim commented Aug 23, 2019

Can someone explain history of that code?

UnityCoroutineHelper.StartCoroutine(SendUnhandledExceptionReports);

I was seeing in git blame:

at some point, coroutine was creating in subscription to unhandled exceptions, then in this commit #187 coroutine creation was moved to exception handling

And now we produce new coroutines for each exception... any reasons for that?

And main question is coroutine creation and execution does not works in multithreaded application, which purpose of using queue with locking?
Why exception handling tracked in coroutine and only for android?

This behaviour complicates solutions like #242.

In teory we want set some properties in some place before exception throwing and clear them after. But async exception tracking make that painfull.

@Jamminroot
Copy link
Contributor

Hey, @cNoNim, thanks for getting in touch.
Please, give us some time to investigate it.

@Jamminroot
Copy link
Contributor

Ok, I've got an update on the problem.
It appears, that at that time we had to run the code in the main thread, since other approaches ended up with error messages of exceptions thrown not being quite clear and understandable.

@cNoNim
Copy link
Author

cNoNim commented Aug 27, 2019

I understand reason for use coroutine, but its not android only problem, and now solution broken, cause StartCoroutine, FindObjectOfType and new GameObject() can (or should) be used from main thread only.

@annakocheshkova
Copy link

@cNoNim as mentioned, calling TrackException without async block / not on main thread causes errors. That's because creating JNI objects should be done either on main thread or using AndroidJNI.AttachCurrentThread() / DetachCurrentThread() (see documentation) which has already been tried and didn't work in our case.
I just verified this behaviour and got

 E/zygote: JNI ERROR (app bug): accessed stale Local 0x9  (index 0 in a table of size 0)
 A/zygote: java_vm_ext.cc:534] JNI DETECTED ERROR IN APPLICATION: use of deleted local reference 0x9

However, if you want, you can use TrackException the way it is convenient for you, by turning off Crashes.ReportUnhandledExceptions(false); .

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

No branches or pull requests

5 participants