Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UwcGetScreenHeight (and Width) build crash #21

Open
CurtisVL opened this issue Mar 24, 2020 · 10 comments
Open

UwcGetScreenHeight (and Width) build crash #21

CurtisVL opened this issue Mar 24, 2020 · 10 comments
Assignees

Comments

@CurtisVL
Copy link

I'm unsure of the specific cause, but in some cases when capturing a window using PrintWindow the following crash occurs using Unity 2019.3.0b7:

Read from location 0000000000000000 caused an access violation.

Stack Trace of Crashed Thread 1732:
0x00007FFD5C2F5372 (uWindowCapture) UwcGetScreenHeight
0x00007FFD5C2EBB2E (uWindowCapture) UwcUpdate
0x00007FFD5C2EFDAB (uWindowCapture) UwcGetScreenHeight
0x00007FFD5C2F00A7 (uWindowCapture) UwcGetScreenHeight
0x00007FFD5C31D3D8 (uWindowCapture) UwcGetScreenHeight
0x00007FFD72037BD4 (KERNEL32) BaseThreadInitThunk
0x00007FFD739ACED1 (ntdll) RtlUserThreadStart

Crash file can be found here:
https://pastebin.com/raw/YCfxs8ij

@CurtisVL CurtisVL changed the title UwcGetScreenHeight build crash UwcGetScreenHeight (and Width) build crash Mar 24, 2020
@Mohipie
Copy link

Mohipie commented Oct 16, 2020

Hi,

I have the same issu. Don't exactly know why for now. Did you find something interesting to solve it ?

Thanks a lot for this plugin !

@hecomi hecomi self-assigned this Dec 14, 2020
@Curtis-VL
Copy link

Curtis-VL commented Jan 26, 2021

To keep this thread alive, I'll update with newer log outputs:

Player.log:
0x00007FFF33695258 (uWindowCapture) UwcGetScreenHeight
0x00007FFF3368BB2E (uWindowCapture) UwcUpdate
0x00007FFF3368FDAB (uWindowCapture) UwcGetScreenHeight
0x00007FFF336900A7 (uWindowCapture) UwcGetScreenHeight
0x00007FFF336BD3D8 (uWindowCapture) UwcGetScreenHeight
0x00007FFF456B7034 (KERNEL32) BaseThreadInitThunk
0x00007FFF4639D0D1 (ntdll) RtlUserThreadStart

2 error.log files attached with more in-depth information on the crash.
error.log
error.log

The issue only happens on first initalizing uWindowCapture, sometimes the windows will show as a white box in Unity before the application closes. After uWindowCapture has started capturing once, the issue does not happen again to my knowledge.

@Curtis-VL
Copy link

Curtis-VL commented Jan 26, 2021

Hi @hecomi,

I've been discussing this crash with someone who experiences it frequently.

I use both uWindowCapture and uDesktopDuplication, they told me one of their window captures were visible and updating, but, upon showing a desktop duplication capture the program crashed with the above error.

Looking through the error.log files from above, I see this section showing a uDD error, though the stack trace shows uWC as what crashed in the end with an access violation error:

ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF0C3994CD)
0x00007FFF0C3994CD (uDesktopDuplication) (function-name not available)
0x00007FFF0C39F49A (uDesktopDuplication) SetFrameRate
ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFF0C39B3CF)
0x00007FFF0C39B3CF (uDesktopDuplication) (function-name not available)

Is it possible there's a conflict when initalizing uDD and uWC at the same time? Or in some specific order?

@Curtis-VL
Copy link

Their error.log is attached, though I believe it's the same as one of the ones above.
error (3).log

@Curtis-VL
Copy link

Curtis-VL commented Jan 30, 2021

Hey Kitaps,

Are you using uDesktopDuplication as well as uWindowCapture? I was starting to suspect there was some issue when using both at the same time, though the issues are so infrequent that it's really hard to diagnose the issue.

In my project at least, it seems this crash only happens on first attempts to capture a window. A system restart, or, several restarts of the application eventually resolves it. It's very strange!

Upload the error.log crash report here if possible. :)

@Curtis-VL
Copy link

Curtis-VL commented Feb 10, 2021

Hi @hecomi,

I've done some further debugging and completely removed 'UwcGetScreenHeight' from the plugin and from everything in Unity, replacing it with a PInvoke.

The crash still persists, this time moving to 'UwcGetScreenY' as the cause.

Going to change everything using 'GetSystemMetrics' to PInvoke in C#, will get back to you on how that goes!

@hecomi
Copy link
Owner

hecomi commented Feb 10, 2021

Thank you for your investigation!

It seems that the internal call to GetSystemMetrics() is a potential crash factor. I'll do some more research and if I can't find a workaround, I'll update the next version to use P/Invoke (or I'd appreciate a pull request).

@Curtis-VL
Copy link

I'll let you know if that crash is resolved, as it doesn't happen frequently (Usually only once per system startup) it's hard to determine if it was fixed or not so I'm waiting for some of my beta testers to report it again. :)

If this solves the issue, I will look into creating a PR of my changes!

@Curtis-VL
Copy link

@hecomi I had the crash again unfortunately! But, this time it points to something that may make more sense.

Stack trace is as follows:
0x00007FF998B64AFE (uWindowCapture) UwcSetCursorTexturePtr
0x00007FF998B5B9A4 (uWindowCapture) UwcUpdate
0x00007FF998B5FB5F (uWindowCapture) UwcSetCursorTexturePtr
0x00007FF998B8E528 (uWindowCapture) UwcSetCursorTexturePtr
0x00007FFA4A1B7034 (KERNEL32) BaseThreadInitThunk
0x00007FFA4A37D0D1 (ntdll) RtlUserThreadStart

Error.log:
error.log

@Kitaps
Copy link

Kitaps commented Mar 5, 2021

Hey @Curtis-VL,

sorry for coming back to you so late. I just saw this.

I'm the replacement from a guy who was working on this project before me, so I don't know everything, but I'll try to give you as much info as I can:

uDesktopDuplication is in the project but it seems to not be used.
What is used is uWindowCapture and a modified uWindowCapture that uses Graphics.CopyTexture.

Also my issue only happens rarely (3 out of 10 times when running the Build version) and this only happens when I am connected to three screens (two 4K and one HD Screens).
When working on only one 4K this issue never occurs (or at least I have not experienced it).

I hope this info can be usefull to you.

error.log
error.log

(To hecomi: In case you red this, your projects are awesome. Super cool)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants