hecomi / uWindowCapture

This allows you to use Windows Graphics Capture / PrintWindow / BitBlt in Windows to capture multiple windows individually and easily use them as Texture2D in Unity.
https://tips.hecomi.com/entry/2021/04/30/230322
MIT License
493 stars 79 forks source link

UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported crash #26

Open Curtis-VL opened 3 years ago

Curtis-VL commented 3 years ago

Hi Hecomi,

Loving the new update, Windows.Graphics.Capture is great!

Though I have found a crash: 0x00007FFF29546122 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF29539287) 0x00007FFF29539287 (uWindowCapture) (function-name not available) 0x00007FFF2953D8F7 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported 0x00007FFF2953DC17 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported 0x00007FFF29570210 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported 0x00007FFF479053FE (KERNEL32) BaseThreadInitThunk 0x00007FFF496A590B (ntdll) RtlUserThreadStart

This same system also returned 'Unsupported' for all displays by uDesktopDuplication, so I assume all their displays are off their main GPU.

They are on Windows 10 version 2004 or later, Windows.Graphics.Capture is supported by the OS version at least.

hecomi commented 3 years ago

Hi Curtis, thank you for the information! I happen to have one laptop PC without a discrete GPU that I can use for the investigation, so I'll try it out on that.

Curtis-VL commented 3 years ago

Hi Hecomi,

That's great, let me know if you need any further information or would like me to test with the user who found the issue!

hecomi commented 3 years ago

I was unable to reproduce this crash on my laptops (1909 / 1903)... However, I am guessing that GraphicsCaptureSession::IsSupported() might be the cause of this crash, so could you try this .unitypackage with this code modified? uWindowCapture-v1.0.2.temp.zip

Curtis-VL commented 3 years ago

I will try this now, thanks!

Curtis-VL commented 3 years ago

That seems to have fixed the crash this user was experiencing, thank you!

Curtis-VL commented 3 years ago

Hi Hecomi,

That same user just reported another crash that seems to be related to the same method, though it could just be a coincidence. Stack trace is as follows:

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc

  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFC693AF2F2)
0x00007FFC693AF2F2 (d3d11) (function-name not available)

  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFC693AA62F)
0x00007FFC693AA62F (d3d11) (function-name not available)

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc.dll

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc

0x00007FFBFCC067C1 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFBFCBF97C3)

0x00007FFBFCBF97C3 (uWindowCapture) (function-name not available)

0x00007FFBFCBFDF77 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported

0x00007FFBFCBFE297 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported

0x00007FFBFCC30F50 (uWindowCapture) UwcIsWindowsGraphicsCaptureCursorCaptureEnabledApiSupported

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc.dll
0x00007FFC6DA453FE (KERNEL32) BaseThreadInitThunk

Fallback handler could not load library D:/Steam/steamapps/common/OVR Toolkit/OVR Toolkit_Data/Mono/libc
0x00007FFC6E52590B (ntdll) RtlUserThreadStart

So far I have not heard of this crash from other users, however, there aren't many in my testing team who have no monitors on the main GPU. They did report that with the crash fix (v1.0.2-temp) Windows.Graphics.Capture is working as intended, the yellow borders show around windows to confirm this.

This appears to have happened upon activating the window GameObject.

hecomi commented 3 years ago

Could you please try again with v1.0.2?

Curtis-VL commented 3 years ago

I am having the user try the new build, I will let you know in a few days!

thomasLopvetVR commented 1 year ago

Hello, This error is still occuring on v1.1.2 and latest commit. windows 10 version 21H2, Unity 2021.2.6 To reproduce it :

It seem that by disabling the cursor, getting the errors of the dll on unity log, capping the streaming at 20fps and using the PrintWindow method for streaming , there is less crashes.