Skip to content

[AI Task] Fix package size query async hang, inline continuations, and callback dict leak - #7839

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

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

Conversation

@JoonghyunCho

Copy link
Copy Markdown
Member

Summary

Fixes three defects shared by the two asynchronous package-size query methods, per the analysis in #7770:

  1. Permanent await hang: the native callback completed the TaskCompletionSource only on the success branch. When the native layer reported failure (IntPtr.Zero handle, or a package-ID mismatch in the instance variant), the returned Task never completed. The failure branch now faults the task with InvalidOperationException.
  2. Inline continuations on the native pkgmgr callback thread: both TCS instances are now created with TaskCreationOptions.RunContinuationsAsynchronously, matching the fixes already applied across the WiFi/Bluetooth/NFC/Remoting/IoTConnectivity bindings.
  3. Callback-registration leak on the synchronous error path: the callbackId → delegate dictionary entry was registered before the P/Invoke call but removed only inside the callback, which never fires when the P/Invoke itself returns an error. The error path now removes the entry under the lock before faulting the task. In GetTotalSizeInformationAsync the dictionary is static, so this leak was process-lifetime.

Changes

  • src/Tizen.Applications.PackageManager/Tizen.Applications/Package.cs: GetSizeInformationAsync — TCS with RunContinuationsAsynchronously, else branch faulting the task, dict entry removal on the synchronous error path.
  • src/Tizen.Applications.PackageManager/Tizen.Applications/PackageManager.cs: GetTotalSizeInformationAsync — identical three-part fix against s_totalSizeInfoCallbackDict.

Mode

Refactoring

Verification

  • Build: passed (dotnet build src/Tizen.Applications.PackageManager/Tizen.Applications.PackageManager.csproj, 0 errors; all warnings pre-existing on unrelated lines)
  • Tests: N/A
  • Benchmark: skipped (sdb error: no device attached)

Public API signatures are unchanged; the success path is byte-for-byte identical. The only behavior change is that a native-callback failure now faults the task deterministically instead of hanging forever — strictly a bug fix.

Fixes #7770

…ck dict leak (Fixes #7770)

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 device list).

@github-actions github-actions Bot added the API15 label Sep 13, 2026
{
_packageManagerSizeInfoCallbackDict.Remove(callbackId);
}
tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get total package size info of " + Id));

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 is the per-package query — "total" is copied from GetTotalSizeInformationAsync and makes the failure message misleading, worth fixing while this error path is being touched.

Suggested change
tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get total package size info of " + Id));
tcs.TrySetException(PackageManagerErrorFactory.GetException(err, "Failed to get package size info of " + Id));

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 ca697ea.

Remove misleading "total" from the per-package size query failure message in Package.GetSizeInformationAsync

Applied-AI-Comments: 4001195337

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant