Skip to content

[AI Task] Fix async-bridge TCS inline continuations and Post<T> permanent hang in Tizen.Applications.Common - #7808

Open
JoonghyunCho wants to merge 2 commits into
mainfrom
ai-task/issue-7736
Open

[AI Task] Fix async-bridge TCS inline continuations and Post<T> permanent hang in Tizen.Applications.Common#7808
JoonghyunCho wants to merge 2 commits into
mainfrom
ai-task/issue-7736

Conversation

@JoonghyunCho

Copy link
Copy Markdown
Member

Summary

Fixes the three async bridges in Tizen.Applications.Common that created TaskCompletionSource without RunContinuationsAsynchronously and completed them from GLib main-loop callbacks, which could run arbitrary user continuations inline inside the main loop dispatch (stall/deadlock risk). Also fixes CoreApplication.Post<T>/CoreTask.Post<T> so a runner() exception no longer leaves the returned Task permanently incomplete (caller hangs forever on await) nor propagates across the GLib reverse P/Invoke boundary.

Changes

  • src/Tizen.Applications.Common/Tizen.Applications/AppControl.csSendLaunchRequestAsync: create the TaskCompletionSource<AppControlResult> with TaskCreationOptions.RunContinuationsAsynchronously.
  • src/Tizen.Applications.Common/Tizen.Applications/CoreApplication.csPost<T>: add RunContinuationsAsynchronously; wrap runner() in try/catch and route exceptions to task.SetException so failures fault the Task instead of hanging the awaiter or crossing the reverse P/Invoke boundary.
  • src/Tizen.Applications.Common/Tizen.Applications/CoreTask.csPost<T>: same fix as CoreApplication.Post<T>.

Mode

Refactoring

Verification

  • Build: passed (dotnet build on Tizen.Applications.Common — 0 errors)
  • Tests: N/A
  • Benchmark: skipped (sdb error: no device attached)

Public API signatures are unchanged; the only behavior change is on the exception path (permanent hang / process crash → faulted Task, matching the Task contract).

Fixes #7736

…guard Post<T> runner exceptions (Fixes #7736)

- AppControl.SendLaunchRequestAsync, CoreApplication.Post<T>, CoreTask.Post<T>:
  create TaskCompletionSource with TaskCreationOptions.RunContinuationsAsynchronously
  so awaiter continuations never run inline inside the GLib main loop dispatch.
- CoreApplication.Post<T>/CoreTask.Post<T>: wrap runner() in try/catch and route
  exceptions to task.SetException, preventing a permanently incomplete Task and
  exception propagation across the reverse P/Invoke boundary.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@JoonghyunCho

Copy link
Copy Markdown
Member Author

⚠️ Benchmark skipped: Encountered an issue with sdb device connection/deployment/execution, so the benchmark could not be run. Manual benchmark verification is required. Error: no sdb device attached (sdb devices returned an empty list).

@github-actions github-actions Bot added the API15 label Aug 16, 2026
Comment on lines +387 to +390
catch (Exception ex)
{
task.SetException(ex);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 [AI Review]
🟡 Suggestion: This catch (Exception) triggers CA1031 (Warning in build/Global.ruleset) in analyzer builds; the same GLib-dispatch pattern in TizenSynchronizationContext.cs suppresses it explicitly.

Suggested change
catch (Exception ex)
{
task.SetException(ex);
}
#pragma warning disable CA1031
catch (Exception ex)
{
task.SetException(ex);
}
#pragma warning restore CA1031

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 [AI Review]
Addressed in 4867a14.

Comment on lines +162 to +165
catch (Exception ex)
{
task.SetException(ex);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 [AI Review]
🟡 Suggestion: Same as in CoreApplication.Post<T> — this catch (Exception) triggers CA1031 (Warning in build/Global.ruleset) in analyzer builds, which the assembly elsewhere suppresses with a pragma for this dispatch pattern.

Suggested change
catch (Exception ex)
{
task.SetException(ex);
}
#pragma warning disable CA1031
catch (Exception ex)
{
task.SetException(ex);
}
#pragma warning restore CA1031

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 [AI Review]
Addressed in 4867a14.

@JoonghyunCho

Copy link
Copy Markdown
Member Author

🤖 [AI Review]
Left 2 inline comments (🔴 0, 🟡 2). See inline for details.


Automated review by AI assistant

Suppress CA1031 via pragma around the GLib-dispatch catch blocks in CoreApplication.Post<T> and CoreTask.Post<T>, matching the existing TizenSynchronizationContext pattern.

Applied-AI-Comments: 3793036964,3793037206
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant