display.capture broken?

I can only get the docs example of display.capture to work. Any changes and it breaks - does not return a captured display object. I am trying to populate a group with simple objects and duplicate it.

In the code below only the last function works…

I’m using the iPhone X skin with:

Copyright © 2009-2018  C o r o n a   L a b s   I n c .

Jan 27 08:48:30.774: Version: 3.0.0

Jan 27 08:48:30.774: Build: 2018.3213

Jan 27 08:48:30.803: Platform: iPhone / x86_64 / 10.12.6 / Intel® Iris™ Graphics 550 / 2.1 INTEL-10.25.17 / 2018.3213 / en-GB | GB | en_GB | en

 

3.3Ghz i7 with 16 Gb…

local function testGenerateShadow() local group = display.newGroup() group.x, group.y = 400, 400 local a = display.newCircle( group, 0, 0, 100 ) a.fill = {0,1,0} local b = display.newRect( group, 0, 0, 300, 25 ) b.fill = {1,0,0} timer.performWithDelay( 1000, function() local cap = display.capture( group ) group:removeSelf() cap.x, cap.y = 200, 200 print("done") end ) end --testGenerateShadow() local function testCapture() local a = display.newRect( 0, 0, 100, 150 ) a.fill = {1,0,0} local b = display.newRect( 0, 0, 200, 100 ) b.fill = {0,0,1} local g = display.newGroup() g:insert( a ) g:insert( b ) g.x, g.y = 200, 200 local function captureWithDelay() local capture = display.capture( g ) g:removeSelf() capture.x, capture.y = 200, 300 end timer.performWithDelay( 1000, captureWithDelay ) end testCapture() local function captureTest() -- https://docs.coronalabs.com/api/library/display/capture.html#example local myObject1 = display.newRect( 50, 50, 100, 150 ) -- Create a rectangle object local myObject2 = display.newCircle( 100, 300, 50 ) -- Create a circle object myObject1.fill = {1,0,0} myObject2.fill = {1,0,1} local group = display.newGroup() group:insert( myObject1 ) group:insert( myObject2 ) local function captureWithDelay() -- Capture the entire group as a new display object local combined = display.capture( group ) -- Position the new display object combined.x, combined.y = 300, 300 -- Remove it group:removeSelf() combined = nil end timer.performWithDelay( 1000, captureWithDelay ) end --captureTest()

I’m convinced that this used to work as I have lots of legacy code which uses a capture and blur effect to generate a blurred version of a display group. Suddenly, this doesn’t work.

Where the above code starts to fails is when .fill is set on one of the two objects added to the group being captured.

works fine for me using 3200

I’m on the latest daily build. Have you tried each function in the code I posted?

@sgs would love input from you on this.

Am I really the only one with this issue?

I get this

I feel like I’m taking crazy pills.

@horacebury can you put together a simple test case and zip it up and share it here?  I’ll try to give it a try, but I can’t spend the time to try and guess at your config.lua and build.settings.

Thanks

Rob

@rob Yes, definitely. Thank you.

Hi Rob,

This link is a video showing what happens on the latest daily build (3215):

https://www.dropbox.com/s/0u6f2jwazgxv9qn/displaycapture.mov?dl=0

This is the code - the second function ‘testCapture()’ demonstrates the issue:

I am running it without a build.settings or config.lua file (though I should note that the result I see is the same as in my much larger application… I can provide that if you have somewhere I can drop you a private link…)

local function testGenerateShadow() local group = display.newGroup() group.x, group.y = 400, 400 local a = display.newCircle( group, 0, 0, 100 ) a.fill = {0,1,0} local b = display.newRect( group, 0, 0, 300, 25 ) b.fill = {1,0,0} timer.performWithDelay( 1000, function() local cap = display.capture( group ) group:removeSelf() cap.x, cap.y = 200, 200 print("done") end ) end --testGenerateShadow() local function testCapture() local g = display.newGroup() g.x, g.y = 150, 150 local a = display.newRect( g, 0, 0, 100, 150 ) a.fill = {1,0,0} local b = display.newRect( g, 0, 0, 200, 100 ) b.fill = {0,0,1} local function captureWithDelay() local capture = display.capture( g ) -- g:removeSelf() capture.x, capture.y = 200, 300 end timer.performWithDelay( 2000, captureWithDelay ) end testCapture() local function captureTest() -- https://docs.coronalabs.com/api/library/display/capture.html#example local group = display.newGroup() local myObject1 = display.newRect( group, 50, 50, 100, 150 ) -- Create a rectangle object local myObject2 = display.newCircle( group, 100, 300, 50 ) -- Create a circle object myObject1.fill = {1,0,0} myObject2.fill = {1,0,1} -- group:insert( myObject1 ) -- group:insert( myObject2 ) local function captureWithDelay() -- Capture the entire group as a new display object local combined = display.capture( group ) -- Position the new display object combined.x, combined.y = 300, 300 -- Remove it timer.performWithDelay( 1000, function() group:removeSelf() combined = nil end ) end timer.performWithDelay( 1000, captureWithDelay ) end --captureTest()

What I’m asking for is a .zip file that I can download, unpack and run in the simulator and if necessary do a device or desktop build. 

This would be really helpful to me.

Also without a config.lua, then there will be possible skin or device dependencies which will make this even harder to track down.

Rob

Thanks Rob, here’s the download link:

https://www.dropbox.com/s/j6dh1hfz8z3q20m/DisplayCapture.zip?dl=0

I’ve included the video file.

You need to call display.capture like:

local combined = display.capture( group, { captureOffscreenArea=true }  )

If you want to have it capture parts of objects that are offscreen. See if that helps with your issue.

Rob

Its not that its not capturing the offscreen parts, rather that it doesn’t capture the object at all.

I’ve added the option table here:

https://www.dropbox.com/s/z1b5j1tg20jmzsl/Archive.zip?dl=0

Updated the video as well.

Another sample based more directly on my work-in-progress:

https://www.dropbox.com/s/ru18wxldsfmubhw/copy.zip?dl=0

This time I was rather surprised to see a pretty bad anomaly appear in the capture:

https://www.dropbox.com/s/0u6f2jwazgxv9qn/displaycapture.mov?dl=0

I tried both “Archive.zip” and “copy.zip” examples.  Both captured and displayed fine.  In Archive.zip, I ran each test with success.

MacBook Pro

Build: 2018.3215

Platform: iPhone / x86_64 / 10.12.6 / NVIDIA GeForce GT 750M OpenGL Engine / 2.1 NVIDIA-10.17.5 355.10.05.45f01 / 2018.3215 / en-US | US | en_US | en

…and I tried “copy.zip” on two other laptops…

Windows 10 Pro (nvidia graphics and intel integrated) w/ build 2018.3217 with no issues.

Mac OS X 10.13 (AMD R9 graphics and intel integrated) w/ build 2018.3217 with no issues.

Really don’t understand this. Just ran a different test which seems to work just fine…

w = 50 r = w/3 s = w/3 d = display.newGroup() d.x, d.y = 50, 100 display.newRect( d, 0, 0, w, w ).fill = {0,0,0} c = display.newCircle( d, 0, 0, r ) cc = display.newCircle( d, 0, 0, r ) e = display.newCircle( d, c.x+w-r, 0, r ) f = display.newCircle( d, e.x+w-r, 0, r ) c.fill = {1,1,1,.9} c.stroke = {1,0,0} c.strokeWidth = s cc.fill = {1,1,1,0} cc.stroke = {0,0,0} cc.strokeWidth = 1 e.fill = {1,1,1,.9} e.stroke = {0,0,1} e.strokeWidth = s f.fill = {1,1,1,.9} f.stroke = {0,0,1} f.strokeWidth = s print(c.width,c.height) print(cc.width,cc.height) print(d.width,d.height) local a = display.capture( d ) a.x, a.y = 50, 50

The error seen in the video of my last post makes me think there’s a problem with the GPU?

You have rebooted right?  None of us can replicate your issue so that does imply something local to you.

Have just rebooted after installing the latest security update. All samples run as described above on build 3218 :S

Concerned that I might have a GPU issue but I have trouble believing that because of the inconsistent behaviour. If the capture would fail surely it would be consistently failing? I don’t what powers its underlying functionality so can’t self diagnose.

@Rob, I’m driven to find out why it is happening. Any suggestions for my further investigation?