Closed fraylopez closed 8 years ago
I second this issue. Losing context seems to clear out all the graphics for me.
@fraylopez - I was actually able to resolve my issue. The logic is somewhat different in the latest update for the Straling Extension graphics package (Mine was up to date as of April or so). The issue comes down to how you restore the graphics - and in my case, a flush was not getting called which prevented the Program3DCache logic from uploading the graphics to the gpu again..
In my version, the 'releaseProgram3D method was never really calling flush, which never removed the program3D from cache, and therefore was never calling the renderer to upload to the gpu after it lost context.
Here's my updated version:
public static function releaseProgram3D( program3D:Program3D ):void
{
if ( !numReferencesByProgramTable[program3D] )
{
throw( new Error( "Program3D is not in cache" ) );
return;
}
var numReferences:int = numReferencesByProgramTable[program3D];
numReferences--;
numReferencesByProgramTable[program3D] = numReferences;
if(numReferences == 0){
flush();
}
}
Again, the new version has this - but the new version is also relying on the new version of starling - which I haven't had time to update to. You may need to trace some code out, but my guess is that this block of code is never getting called after losing context and therefore is never updating the gpu with restored graphics. My issue is that the code was never getting back into the program3D to restore the graphics again.
if ( program3D == null )
{
program3D = programByUIDTable[program3DUID] = context.createProgram();
uidByProgramTable[program3D] = program3DUID;
program3D.upload( vertexShader.opCode, fragmentShader.opCode );
numReferencesByProgramTable[program3D] = 0;
cacheSize++;
}
A fix for this has been submitted
Hi,
There are several issues about this. Just in case, make sure your are not using the .swc package which is OUTDATED.