Lot of "Cannot read property 'location' of undefined" errors in HTML5 + Starling

The setup:
OpenFL 8.9.5 with Lime 7.6.3
Starling 2.5.0
Target is HTML5 only
Textures are ATF Textures (DXT5 for Desktop, ETC1 for Android, PVRTC for iOS)

When using ATF textures in OpenFL HTML5 builds, you cannot longer use untextured Quads etc. Simply try to activate the Stats in Starling, the game will crash instantly :frowning: Ok, not really a showstopper, as long as you now thisā€¦ I never looked any deeper into the guts of OpenFL what might be the problem.

Ok, but now our game went live and a lot of people started playing. We are logging as many errors as possible. Our top error so far has been: ā€œCannot read property ā€˜locationā€™ of undefinedā€ Here is the full (minimized) stack:

Error: TypeError: Cannot read property ā€˜locationā€™ of undefined
at sc.__flushGLTextures <-- Context3D
at sc.__flushGL
at sc.drawTriangles
at lc.render
at Tj.render
at Mb.drawBatch
at ll.finishBatch
at Mb.finishMeshBatch
at Mb.drawMask <-- Starling Painter
at ha.render

100% of the devices are Android, so ETC1 textures are used. The only location where this can happen is the gl.uniform1i(ā€¦) call. Really donā€™t now why this is not working. Textures are loaded correctly etc. I commented the second one out (after __bindGLTexture2D(null);). This is not helping on the issue itself, but as a side effect fixes the untextured Quad / Stats crash problem mentioned in the second paragraph ^^. Not sure if it is safe to comment out? Tried it here on my local machine and everything looks exactly the same. Even if i comment out both calls to gl.uniform1iā€¦

Textures are loaded via the classic Starling AssetManager. We had to modify the AssetManager to get the ATF textures to work:

In ā€œprocessRawAssetā€

options.onReady = prependCallback(options.onReady, function(_):Void
{
addTexture(name, texture);
onComplete();
});

is not workingā€¦ We commented it out and instead added

   addTexture(name, texture);
   onComplete();

Using the Async version results in an exception in ByteArrayā€¦

Would this fix be related?

Okay try this one:

Sadly the fix for the AtfTextureFactory isnā€™t working. Iā€™m still getting the exception in ByteArray :frowning:
The Context3D fix looks good. This will go live with the next patch (thursday hopefully). I can give you feedback a few days later.

1 Like

We patched this morning and the ā€œlocationā€ errors are still present :frowning:

Hmm this patch fixed the Starling demo for me and I could not reproduce the error anymore

Do you have problems using the Starling demo? Any ideas how to reproduce?

The starling demo is running fine. The problem with the undefined ā€œlocationā€ is not the same as the starling ā€œuntexturedā€ error. Unfortunately I cannot reproduce the error myself. It happens only on Android and only in the callstack mentioned above. None of my Android devices shows the error. But Android in the wild is a different story. So many different devicesā€¦ The mask on this Button is using a custom MeshStyle. Could this be the issue?

Here is the code for the TextureMaskStyle.hx

I suppose that shader may/may not use COMPRESSED_ALPHA (calling FilterEffect.tex which calls createAGALTexOperation under the hood) which was the issue I was seeing earlier when I replicated the problem

When using a sampler with alpha we add extra attributes to the generated GLSL to handle it:

I just wonder if the issue is that the current program has no alpha support or why this code (or similar code?) is mismatching:

Perhaps we just need more null checks to make sure the program does indeed have a texture _alpha and _alphaEnabled?

Could you try wrapping this line:

with

if (__state.program.__agalAlphaSamplerEnabled[sampler] != null) {

}

?

Sure, no problem. Looks like an easy fix for the moment. The question is, why is this failing on some Android devices :slight_smile: But thanks for the help!