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

Invoke function is broken

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

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

評価

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

調査の方向性

ViewImplementationBase.Invoke から開始し、DoInvokes と DoRender を経由するレンダリングパスを追跡して、x.ResetEvent.Reset() の null 参照に焦点を当てます。提供された初期化を使用して、報告されたバックグラウンドスレッドからの Invoke のケースを再現し、メインスレッドのレンダリングループとタスクが NullReferenceException なしで完了することを確認します。

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

説明

bug

Summary

When trying to use the Invoke function from IView i receive an error message.

Steps to reproduce

  • Platform: Desktop
  • Framework Version: .NET 10
  • Silk.NET Version: 2.23.0
  • API: OpenGL
  • API Version: OpenGL 4.6 Core

Initiation:

var initOptions = WindowOptions.Default with
{
    IsVisible = false,
    VSync = false,
    Size = new(1280, 720), 
    API = new GraphicsAPI
    {
        API = ContextAPI.OpenGL,
        Profile = ContextProfile.Compatability,
        Flags = ContextFlags.ForwardCompatible,
        Version = new APIVersion(4, 6)
    },
    FramesPerSecond = 60
};

Issue

Code
Task.Run(() =>
{
    Thread.Sleep(100);
    Window.Main.MeGLFW.Invoke(() => Console.WriteLine("error"));
});
Errors

On the main Thread:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Silk.NET.Windowing.Internals.ViewImplementationBase.DoInvokes()
   at Silk.NET.Windowing.Internals.ViewImplementationBase.DoRender()
   at Silk.NET.Windowing.WindowExtensions.<>c__DisplayClass2_0.<Run>b__0()
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Run(Action onFrame)
   at Silk.NET.Windowing.Glfw.GlfwWindow.Run(Action onFrame)
   at Silk.NET.Windowing.WindowExtensions.Run(IView view)
   at /* My App Init */

And in the Task:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Silk.NET.Windowing.Internals.ViewImplementationBase.Invoke(Delegate d, Object[] args)
   at /* Task.Run() */
   at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
public object Invoke(Delegate d, params object[] args)
{
    var rentalIndex = Interlocked.Increment(ref _rented) - 1;
    EnsureArrayIsReady(rentalIndex);
    ref var x = ref _pendingInvocations![rentalIndex];
    x.Delegate = d;
    x.Data = args;
    x.ResetEvent.Reset(); // <- Here
    x.IsComplete = false;
    x.ResetEvent.Wait();
    var ret = x.Data[0];
    _returnArrayPool.Return(x.Data);
    x.Delegate = null;
    x.Data = null;
    return ret;
}
主要言語
C#
スター
5.2k
フォーク
480
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

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

dotnet/Silk.NET のほかの issue

dotnet/Silk.NET の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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