Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Using AnswerAsync() with Task.Run() causes the mediasession to be

オープン
#833 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
30/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
csharp

調査の方向性

まず CallsOnIncoming、AnswerAsync()、Task.Run()、CallsOnUpdated の間の相互作用を再現し、MediaSession が null になるタイミングを記録します。これらのエントリポイントにまたがる通話とメディアセッションのライフサイクルを追跡し、Task.Run() の有無で実行を比較します。完了とは、応答された通話が一貫して MediaSession を公開し、拒否された通話が引き続き安全にフィルタリングされる状態を指します。

索引モデルが issue の本文から書いたものです。

説明

Describe the issue
We tried to wrap call.AnswerAsync() inside of Task.Run() and it resulted in an issue where the MediaSession on a ICall was often null instead of the expected value.

Code Snippet
This code works as expected

ICommunicationsClient client;
client.Calls().OnIncoming += CallsOnIncoming;
client.Calls().OnUpdated += CallsOnUpdated;

private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs<ICall> args)
{
  foreach (var call in args.AddedResources)
  {
    if (callShouldBeAccepted()) // business logic to decide if we answer or reject
    {
      // Here we answer the call:
      ILocalMediaSession session = CreateMediaSession(/*...*/);
      call.AnswerAsync(session, /*...*/);
    } else {
      // Here we reject it
      call.RejectAsync(RejectReason.Forbidden);
    }
  }
}

private void CallsOnUpdated(ICallCollection sender, CollectionEventArgs<ICall> args)
{
  foreach (var call in args.AddedResources)
  {
    // rejected calls also show up here for some reason, so we filter those:
    if (call.MediaSession is null)
    {
      // rejected calls don't have a MediaSession
      _logger.LogInformation("Skipping call init (no MediaSession)");
      continue;
    }
    // otherwise, handle the call as usual...
    // <call handling logic here>
  }
}

Adding Task.Run() breaks things

Task.Run(async () => await call.AnswerAsync(session, /*...*/));

Now the MediaSession is often null for calls that we answered. And we see this in the logs:

Skipping call init (no MediaSession)
Skipping call init (no MediaSession)
Skipping call init (no MediaSession)

In our testing, it happens approximately 15-30% of calls, but this varies. My guess is an issue due to the task being scheduled on a different thread.

Expected behavior
It should behave the same way it did before using Task.Run()

Graph SDK (please complete the following information):

  • Version 1.31.0.225 (but the issue is the same with older versions)

Call ID
Provide the list call ids that encountered this issue. Include the time in UTC/GMT when these call have occurred.

Logs
If required, please add logs from the SDK. (Please remove any PII from the logs before uploading)

Additional context
Add any other context about the problem here.

主要言語
言語のデータがありません
スター
252
フォーク
276
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoftgraph/microsoft-graph-comms-samples のほかの issue

microsoftgraph/microsoft-graph-comms-samples の issue をすべて見る

似ている issue

Audio/Video & RTC の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。