Screen Flicker After Connecting To Google Play

After I authenticate to Google Play Game Services, I get massive distracting screen flicker.

I’ve tried authenticating both after the game is fully loaded (via jni) and before the game is loaded at all (via OFActivity).

It seems to be something to do with texture reloading. I’ve tried putting the texture reloading into a different thread (but this didnt work at all).

The screen flicker is pretty drastic. Anyone else experience this?

We had the same problem 1 year ago when implementing Google Play Licensing. I don’t remember exactly which fix solved it. But i check our own codes now and i see we wrote 2 major fixes, where probably one of them was done to solve this problem.


I. In the scrJava/yourpackage/yourOFActivity.java, there are these lines:

        @Override
        public void onCreate(Bundle savedInstanceState)
            super.onCreate(savedInstanceState);
            String packageName = getPackageName();
            ofApp = new OFAndroid(packageName,this);
        }
    
        @Override
        protected void onPause() {
            super.onPause();
            ofApp.pause();
        }
  
        @Override
        protected void onResume() {
            super.onResume();
            ofApp.resume();
        }

Instead of above lines, try these new lines:

@Override
public void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
}
        
private void startOF() {
    String packageName = getPackageName();
    ofApp = new OFAndroid(packageName,this);
}
    
@Override
protected void onPause() {
    super.onPause();
    if (ofApp != null) ofApp.pause();
}
  
@Override
protected void onResume() {
    super.onResume();
    if (ofApp != null) ofApp.resume();
    else startOF();
}

II. Try putting all texture loading operations into the reloadTexture() void of the ofApp.cpp.


I fixed the screen flicker by changing ofAppAndroidWindow.cpp:

void Java_cc_openframeworks_OFAndroid_onSurfaceCreated( JNIEnv*  env, jclass  thiz ){
	if(appSetup){
		ofLogNotice("ofAppAndroidWindow") << "onSurfaceCreated";
		if(!surfaceDestroyed){
			surfaceDestroyed = true; // fixes screen flicker
           ......


void Java_cc_openframeworks_OFAndroid_render( JNIEnv*  env, jclass  thiz )
{
	// fixes screen flicker
	if(surfaceDestroyed || paused)
	{
	    ofPushStyle();
	    ofSetColor(0, 0, 0, 255);
	    ofRect(-sWindowWidth, -sWindowHeight, sWindowWidth*2, sWindowHeight*2);
	    ofPopStyle();
		return;
	}
.....
1 Like