Skip to content

Commit 0ba99db

Browse files
committed
ANDROID: fix rendering freeze upon startup
1 parent 71799c7 commit 0ba99db

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

loaders/android/bootstrap.java.in

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ import android.hardware.SensorManager;
7272
@ANDROID_JAVA_ADDITIONS@
7373

7474
public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@ SensorEventListener{
75-
private android.view.View current_ContentView = null;
75+
private static android.view.View current_ContentView = null;
7676
private SensorManager mSensorManager;
7777
//Variable declarations needed for modules, e.g. gps
7878
@ANDROID_JAVA_VARIABLES@
@@ -142,16 +142,15 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
142142
}
143143
}
144144
current_ContentView = view;
145-
super.setContentView(current_ContentView);
146145
}
146+
super.setContentView(current_ContentView);
147147
if(current_ContentView instanceof android.opengl.GLSurfaceView) {
148148
((android.opengl.GLSurfaceView)current_ContentView).onResume();
149149
}
150150
}
151151

152152
@Override
153153
protected void onCreate(Bundle savedInstanceState) {
154-
current_ContentView = null;
155154
super.onCreate(savedInstanceState);
156155
Thread.setDefaultUncaughtExceptionHandler(
157156
new Thread.UncaughtExceptionHandler() {
@@ -174,7 +173,6 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
174173
mGLView = new xGLSurfaceView(this);
175174
// This may better before other pieces
176175
nativeInstanceInit(getApplicationContext().getPackageCodePath().toString(), getFilesDir().toString());
177-
setContentView(mGLView); // MUST NOT run before nativeInstanceInit completed
178176
}
179177

180178
mSensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
@@ -183,6 +181,9 @@ public class @SYS_APPNAME@ extends Activity implements @ANDROID_JAVA_IMPLEMENTS@
183181
// Additions and permissions needed by modules, e.g. gps
184182
@ANDROID_JAVA_ONCREATE@
185183

184+
// MUST NOT run before nativeInstanceInit completed
185+
// and MUST NOT run before permission checks
186+
setContentView(current_ContentView==null ? mGLView : current_ContentView);
186187
// start EVENT_IDLE
187188
if(idle_tmScheduleRate > 0) idle_tm.scheduleAtFixedRate(idle_task, 0, idle_tmScheduleRate);
188189
}

0 commit comments

Comments
 (0)