CaptureService:CaptureScreenshot() never completes under certain conditions in studio

Sometimes when you use CaptureService:CaptureScreenshot() in studio the onCaptureReady callback never fires depending on what’s actively rendered in the viewport. The exact conditions this happens under are unclear, but a solid color seems to cause the issue to occur consistently.

Observe in the video that when capturing the skybox there’s no issue printing the temporary capture uri that results from the CaptureScreenshot method. However, when enabling the screen gui (which is simply a solid black frame) the CaptureScreenshot method never fires the onCaptureReady callback.

Repro4.rbxl (61.0 KB)

Observations of note:

  • As far as I know this is a relatively recent issue that started occuring in the last few days.
  • The method seemingly works fine on the client - this is a studio only issue.
  • This issue occurs both when the game is running and when it’s not.
9 Likes

I ran into this as well with my own plugin that uses CaptureService after I updated studio to the latest version. The weird part about it is that I only consistently run into it when my viewport’s resolution is under 600x600.

My repro is a little bit different:

  1. Set your viewport’s resolution to 512x512 with the Device Emulator (or just resize studio)
  2. Run the snippet below and watch it eventually fail to take a screenshot
local TIMEOUT_DURATION = 10
local SCREENSHOT_COUNT = 100

local function takeCapture()
	local takenScreenshotTempAssetId = nil
	
	local startTime = tick()
	
	local CaptureService = game:GetService("CaptureService")
	CaptureService:CaptureScreenshot(function(tempAssetId)
		takenScreenshotTempAssetId = tempAssetId
	end)

	repeat task.wait() until takenScreenshotTempAssetId or (tick()-startTime) > TIMEOUT_DURATION

	return takenScreenshotTempAssetId
end

for index = 1,SCREENSHOT_COUNT do
	workspace.Camera.CFrame *= CFrame.fromEulerAnglesYXZ(
		math.random() * math.pi, 
		math.random() * math.pi,
		0
	)
	game:GetService("RunService").PreRender:Wait()

	print(`Capturing screenshot {index}/{SCREENSHOT_COUNT}`)

	local takenCapture = takeCapture()
	if takenCapture==nil then
		warn(`Failed to capture screenshot {index}/{SCREENSHOT_COUNT}`)
		break
	end
	
	print(`Captured screenshot {index}/{SCREENSHOT_COUNT}`)
end
3 Likes

Hello, thank you for reporting this! We’ve flipped a flag that we think should resolve this issue.

I’ve tested the fix with your script and it seems to work, but please let us know if this issue persists.

2 Likes

As far as I can tell this has fixed the issue. Thanks!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.