-
-
Notifications
You must be signed in to change notification settings - Fork 51
Crash trying to capture screenshot when ensure() is triggered soon after starting PIE (Viewport is null) #1329
Description
Environment
Sentry SaaS (sentry.io)
Which version of the SDK?
1.8.0
Which version of Unreal?
5.7.2
Steps to Reproduce
It's complicated. I reproed it twice in a row, and then it stopped... One of our artists could repro it consistently.
We have some custom engine code that happens to trigger an ensure in the RHIThread, under certain conditions. The details probably aren't important. All we have to do is enter PIE (Play In Editor), and then the ensure triggers pretty much straight away.
What happens then is that we get into SentryScreenshotUtils::CaptureScreenshot(), and GameViewportClient->Viewport is null. GEngine->GameViewport is actually set, so the existing checks pass, and then it crashes at line 30.
Most likely some race condition. I assume that UGameViewportClient::SetViewportFrame is about to be called in another thread, but hasn't yet.
Side note: A bit scary that there is no thread synchronisation at all here, apparently. Even simple pointer assignment isn't always guaranteed to be atomic, I believe.
Strangely, when I try it in the debugger, I can enter PIE and start playing, and UGameViewportClient::SetViewportFrame is only called afterwards, when I exit PIE. Not sure what to make of this.
Adding a simple null check in SentryScreenshotUtils::CaptureScreenshot(), beneath the existing checks would make all this safe, I think. Even if I can't reliably prove it. Like the comment says, screenshot generation is on a best-effort basis, so no screenshot is better than a crash. With that in mind, maybe the exact details for triggering a repro don't matter. As long as UGameViewportClient can exist while SetViewportFrame hasn't been called yet, this crash will be possible.
What do you think?
Thanks.
Metadata
Metadata
Assignees
Labels
Fields
Give feedbackProjects
Status
Status