Repository navigation
Docs: exceptions lost on Mono ThreadPool work items, and late Task exceptions #270
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
Open
krassx
wants to merge
5
commits into
main
Choose a base branch
from
docs/mono-pool-task-exceptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e7eb129
Docs: exceptions lost on Mono ThreadPool work items, and late Task ex…
krassx 7ef86a4
Docs: qualify the Mono pool claim, state the thread/async void measur…
krassx 0110060
Docs: scope the async void claim, state the GC observation window, fi…
krassx a097978
Changelog: state the GC observation window
krassx 95801f1
Changelog: use the measured 16 s window, drop 'never'
krassx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity: P2 Medium
Location:
Documentation~/index.md:209(same call in theContinueWith(..., OnlyOnFaulted)sentence at :213)Problem: The workaround this section exists to teach is
catch+Bugsee.LogExceptioninsideThreadPool.QueueUserWorkItem. On Android that is a public JNI call with no attach.AndroidBridge.SendManagedPayloadbuilds aUnityManagedExceptionand callsBugsee.logExceptionon the calling thread and does not enterAndroidJniScope. Span APIs andGetLauncheddo, because this same file already states the JVM “aborts the process on a JNI call from an unattached thread” (Documentation~/index.md:683;JniAttachPolicy/AndroidJniScopecomments: CheckJNI “use of deleted local reference”, Galaxy Tab A 8.0).ExceptionPipeline.DispatchPayloadhops handled auto-capture onto the Unity main thread before the same JNI; the publicBugsee.LogExceptionpath does not. SampleSignatureThreadsE2Eonly callsBugsee.LogExceptionfrom a worker afterAndroidJNI.AttachCurrentThread().Impact: On the configuration this paragraph measured (Android Mono ARMv7), following the snippet can replace a silently lost exception (process keeps running) with a hard abort.
ContinueWith(..., OnlyOnFaulted)plusBugsee.LogExceptionis the same pool-thread JNI call.Scenario: Copy the snippet onto the Honor / Unity 2021.3.45f1 Mono player.
DoWork()throws,catchruns on a CLR thread-pool thread (IsThreadPoolThreadtrue, the caseJniAttachPolicytreats as AttachDetach).Bugsee.LogException→SendManagedPayload→new AndroidJavaObject(...)with noJNIEnv. Auto-capture ofUnobservedTaskExceptionwould have been safe because it is handled andMainThreadDispatcher.Runs the send; this snippet bypasses that hop.Fix: Point the snippet at a path that is already safe from a background thread:
Debug.LogException(e)(CHANGELOG: backgroundDebug.LogExceptionnow reports; the pipeline hops handled sends to main). Or keepBugsee.LogExceptionand say it must run on the Unity main thread, or afterAndroidJNI.AttachCurrentThread()(and detach a pool thread), matchingsigthreads. The durable product fix isusing (AndroidJniScope.Enter())aroundSendManagedPayload, which this docs-only PR does not have to include.