Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Invoke function is broken

Đang mở
#2,597 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp
Lĩnh vực
computer-graphics

Hướng nghiên cứu

Bắt đầu từ ViewImplementationBase.Invoke và theo dõi đường dẫn render qua DoInvokes và DoRender, tập trung vào tham chiếu null tại x.ResetEvent.Reset(). Tái hiện trường hợp Invoke trên background thread đã được báo cáo bằng phần khởi tạo được cung cấp và xác minh rằng vòng lặp render của main thread và task hoàn tất mà không có NullReferenceException.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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;
}
Ngôn ngữ chính
C#
Star
5.2k
Fork
477
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của dotnet/Silk.NET

Tất cả issue của dotnet/Silk.NET

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.