iOS 9 graphics transparency issue

Under iOS 9, the transparent backgrounds for my game’s graphics are rendered black. Does anyone know why this might be and how to fix it?

I should add that this issue doesn’t appear when viewing the game on an iPad Air with iOS 9. But it does on an iPhone 6.

Hi @Dotnaught,

Can you give more details on these images? Size, format, file size, etc.?

Thanks,

Brent

I’m having the same issue with iOS 9 and iPhone 6. iOS 9 works fine on other devices though. https://pbs.twimg.com/media/CPj6lXoUAAAg1bD?format=pjpg&name=large
Unfortunately I launched my game as ios9 was released and didn’t catch it in time.

Hi guys,

This only happens on iPhone 6? Which version of iOS 9… 9.0 or 9.0.1? This seems like a potential Apple bug to me, if it’s isolated to a specific device. Have you searched online to see if other developers are having this issue with non-Corona-built apps?

Brent

It happens only in iPhone 6 (not sure about 6 plus) with ios9 and 9.0.1

I’ll have to search a little later. Stuck commuting today.

Cheers!

Tired iOS 9 and 9.0.1, both show the same problem on the iPhone 6.

They’re PNGs.

2KB at 1x (also present in 2x and 4x)

255x58, RGB color mode, Depth 8, Interlace Type 0

Here’s how they’re being loaded:

local platform = display.newImageRect(mainGroup.objectGroup, "images/platform"..object["type"]..n..".png", object["widthHeight"][1], object["widthHeight"][2]) platform.anchorX=0.5; platform.anchorY=0; platform.x = object["position"][1]+(480\*object["screen"]); platform.y = object["position"][2]; platform.name = "platform" ... local physicsShape = { -rad, -height, rad, -height, rad, platform.height\*0.5, -rad, platform.height\*0.5 } physics.addBody( platform, "static", { friction=0.1, bounce=0, shape=physicsShape} );

and config:

application = { content = { -- graphicsCompatibility = 1, width = 320, height = 480, scale = "zoomStretch", imageSuffix = { ["@2x"] = 2, ["@4x"] = 4, }, }, }

Hi @Dotnaught,

Can you file a bug report on this, including the basic project (and the images that are effected) so that we can test on our side? I’m not sure it’s a Corona bug or not, but we can at least test to see if it’s reproducable on our end.

Thanks,

Brent

Ok, will do.

Hi @Dotnaught,

I forgot to mention, when you file the case and received the case #, please post it back here for reference.

Brent

I filed it (twice I think, accidentally) but haven’t received a case number. Will post if I do.

Hi guys,

I figured out what’s causing the issue. 

you can see here, the transparent parts of the star PNGs are black:  https://pbs.twimg.com/media/CP9pnHJUsAAKzjq.jpg:large

but here, all good: https://pbs.twimg.com/media/CP9zTXjUcAAp01Q.jpg:large

The problem seems to be when I added a hue to the sprite/image. I took the hue filter away from the stars and it fixed the problem.  Now the problem is how to get hues working again.

Hope that helps!

Cool, thanks. Looking at my code, there’s no hue filter, only brightness and it’s attached only to one of the affected image types. Other affected images don’t have a filter so it may be that there’s an issue with the filter implementation in general.

We have received numerous complaints from customers, and we are pretty sure they are related to this issue as well. 

@Brent is this something you guys are already working on? 

Hi guys,

All I can surmise at this point is that there is a specific issue with the hue filter and the GPU on the iPhone 6. We’ll need to test this on our in-house devices, but if you need an “immediate” fix, then I suspect you’ll need to find another method than the hue filter for your images. I realize that might not be a realistic solution in the short term, but GPUs can vary widely in behavior and we’ll need to explore what may be happening here.

Brent

Thanks Brent,

I’ll use multiple sprite sheets for now. Best of luck finding a fix!

cheers,

-josh

The built-in hue shader does not support transparent regions for performance reasons b/c supporting 0 alpha in a texture would require an if-else branch in the shader.

 

If you apply the hue filter on a texture with regions of 0 alpha, you will get undefined behavior in those regions (divide by 0 is undefined in a shader), meaning the end result will vary from device to device.

 

Here’s a version up on our Shader Playground of the hue shader that supports 0 alpha, though with a performance penalty due to the if-else branch. You can vary the “angle” in the first component of CoronaVertexUserData: https://goo.gl/RaXU3N

Thanks for the explanation, Walter. One of the affected images I have uses the brightness filter, so I assume it too doesn’t support 0 alpha (in iPhone 6 GPU I guess since it’s fine on iPad Air).

Is there another filter beside hue and brightness that can handle 0 alpha? Ideally, I can just swap a different filter in and live with the varied visual effect, since the main purpose of the effect to convey a state change in the player object.

Ah, yes brightness is also affected. Both hue and brightness have to convert from colors with pre-multiplied alpha, to those without, and that requires a divide by alpha.

I’m not seeing any other filters that rely on a divide by alpha, so I think it’s just those two.

Hi there,

This is also a huge problem for our app that is currently released. We use brightness on thousands of images in our app and they are all displaying incorrectly.

As a temporary solution we are considering looking at the device and if it happens to be an iphone 6’s, then we will not use brightness. Would this temporary solution be possible?

Thank you!

@jhow, you can create a custom shader effect (https://docs.coronalabs.com/daily/guide/graphics/customEffects.html)

Here’s a version of the brightness shader that accounts for 0 alpha in the Shader Playground, the first component of CoronaVertexUserData is the “intensity”: https://goo.gl/Urhkj2