About Store Forum Documentation Contact
Donations:
289$/mo



Post Reply 
textstyles error on iOS
Author Message
yvanvds Offline
Silver Supporter

Post: #1
textstyles error on iOS
Hey

I think there's a problem with using textstyles on iOS. When I try to use a textstyle, the application crashes. I've included a project and a screenshot of the error. (The project includes a gui skin with a custom textstyle. Remove the textstyle and it will work. Accessing the textstyle directly also causes the error.)

When using the iOS simulators the app works, but it crashes when you use a real device.


Regards,

yvan


Attached File(s) Image(s)
   

.zip  textstyles test.EsenthelProject.zip (Size: 50.32 KB / Downloads: 2)
11-23-2016 12:40 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: textstyles error on iOS
Hi,

What kind of iPad do you have?

I've just tried running this on Android (Note 4), iOS (iPad Mini 2) in both armv7/arm64 (32/64 bit) and all works OK.

The problem looks to be related to loading Font image texture.
On Android and iOS Font is stored in ETC2_A8 format, but if the format is not supported on your device, then it converts it to L8A8. I've just tried both methods and both work OK.
11-24-2016 12:35 AM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Silver Supporter

Post: #3
RE: textstyles error on iOS
I tested with an iPad mini, not mini 2. I got one user reporting this with a iPhone 4s. That's how i found out something was wrong, because the simulators all work.

On my android phone everything works like it should.
11-24-2016 01:42 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: textstyles error on iOS
I think iPad Mini 1 and iPhone 4s don't support ETC2_A8 format, in that case, the font should fallback to L8A8 format.

When an Image is loaded, then is called:
Graphics\Image IO.cpp
Code:
static Bool Load(Image &image, File &f, C ImageHeader &header, IMAGE_TYPE type_on_fail)

with the line:
Code:
if(image.createTryEx(want.size.x, want.size.y, want.size.z, want.type, want.mode, want.mip_maps, 1, type_on_fail)) // don't use 'want' after this call, instead operate on 'image' members

Then inside:
Graphics\Image.cpp
Code:
glCompressedTexImage2D(GL_TEXTURE_2D, 0, ImageTI[hwType()].format, hwW(), hwH(), 0, size, temp.elms() ? temp.data() : null);
attempts to setup the texture of desired compressed format

but if this format fails, then it tries another one (uncompressed)
Code:
Bool ok=(glGetError()==GL_NO_ERROR);
if( !ok && type_on_fail)

In your case, ok should be false, and texture should get created as L8A8.
Can you compile engine in debug mode, and verify that it's indeed the case?
When attempting to load your "Font" inside "Bool Init" ?

1) run Esenthel Builder and compile iOS in DEBUG mode

2) Modify your code to following:
Code:
void InitPre()
{
   EE_INIT();
   //Gui.default_skin = UID(2932164563, 1175793352, 1139732360, 3412372619);
}

bool Init()
{
   Font font;
   font.load(EncodeFileName(UID(1420520785, 1917302748, 4184509362, 3843416765)));
   return true;
}

void Shut()
{
  
}

bool Update()
{
  
   return true;
}

void Draw()
{
   D.clear(WHITE);
}
insert a breakpoint when loading the font.
And verify what happens when attempting to create and load that image, by doing debug step into

I will do some more tests too.
11-24-2016 01:59 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: textstyles error on iOS
You can skip the above, and first try this workaround:

My initial analysis is this is a bug in which iOS falsely reports success in creating texture formats which aren't supported.

Replace Graphics\Display.cpp:

Code:
if(context=[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2 sharegroup:[MainContext sharegroup]])return true;
into
Code:
if(context=[[EAGLContext alloc] initWithAPI:[MainContext API] sharegroup:[MainContext sharegroup]])return true;

and

Code:
MainContext=[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
into
Code:
if(MainContext=[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3])_shader_model=SM_GL_ES_3;else
      if(MainContext=[[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2])
      {
        _shader_model=SM_GL_ES_2;
         // iOS has a bug in which it falsely returns success for creating ETC formats on OpenGL ES 2 even though they're not supported, so as a workaround, disable them completely
         ConstCast(ImageTI[IMAGE_ETC1   ].format)=0;
         ConstCast(ImageTI[IMAGE_ETC2   ].format)=0;
         ConstCast(ImageTI[IMAGE_ETC2_A1].format)=0;
         ConstCast(ImageTI[IMAGE_ETC2_A8].format)=0;
      }

Please let me know if this helps.
11-24-2016 03:41 AM
Find all posts by this user Quote this message in a reply
yvanvds Offline
Silver Supporter

Post: #6
RE: textstyles error on iOS
Thank you, Greg. Problem solved!

I think the underlying issue is that these devices are not supported by Apple any more. But at least we can use them a little while longer now :-)

Will you also change this in the official code one way or another? I can imagine you won't because it only affects these old devices. In that case I have to remember changing it myself when i still need to support them.
11-24-2016 10:52 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: textstyles error on iOS
Hi,
Glad this solved the problem smile
Yes I will include these changes in official source code branch.
11-24-2016 10:34 PM
Find all posts by this user Quote this message in a reply
Post Reply