[Scummvm-git-logs] scummvm master -> 23c066d00e830dabb10d5b827855cf080ca800a3

antoniou79 a.antoniou79 at gmail.com
Tue Dec 1 17:44:05 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
23c066d00e ANDROID: Attempt to fix IllegalArgumentException for chooseEglConfig()


Commit: 23c066d00e830dabb10d5b827855cf080ca800a3
    https://github.com/scummvm/scummvm/commit/23c066d00e830dabb10d5b827855cf080ca800a3
Author: antoniou (a.antoniou79 at gmail.com)
Date: 2020-12-01T19:42:01+02:00

Commit Message:
ANDROID: Attempt to fix IllegalArgumentException for chooseEglConfig()

Crash reports mentioning this exception came from Play Store

stacktrace looked like the following:
java.lang.RuntimeException:
		  at org.scummvm.scummvm.ScummVM.run (ScummVM.java:144)
		  at java.lang.Thread.run (Thread.java:919)
		Caused by: java.lang.IllegalArgumentException:
		  at com.google.android.gles_jni.EGLImpl.eglGetConfigAttrib (Native Method)
		  at org.scummvm.scummvm.ScummVM$EglAttribs.<init> (ScummVM.java:339)
		  at org.scummvm.scummvm.ScummVM.chooseEglConfig (ScummVM.java:440)
		  at org.scummvm.scummvm.ScummVM.initEGL (ScummVM.java:180)
		  at org.scummvm.scummvm.ScummVM.run (ScummVM.java:133)

Changed paths:
    backends/platform/android/org/scummvm/scummvm/ScummVM.java


diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
index 1a5fb455ca..0852ddeb88 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVM.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java
@@ -340,16 +340,24 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 		EGL10.EGL_TRANSPARENT_BLUE_VALUE
 	};
 
-	final private class EglAttribs extends LinkedHashMap<Integer, Integer> {
+	final private class EglAttribs  {
+
+		LinkedHashMap<Integer, Integer> _lhm;
+
 		public EglAttribs(EGLConfig config) {
-			super(s_eglAttribs.length);
+			_lhm = new LinkedHashMap<>(s_eglAttribs.length);
 
 			int[] value = new int[1];
 
+			// prevent throwing IllegalArgumentException
+			if (_egl_display == null || config == null) {
+				return;
+			}
+
 			for (int i : s_eglAttribs) {
 				_egl.eglGetConfigAttrib(_egl_display, config, i, value);
 
-				put(i, value[0]);
+				_lhm.put(i, value[0]);
 			}
 		}
 
@@ -439,6 +447,14 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 
 			return s;
 		}
+
+		public Integer get(Integer key) {
+			if (_lhm.containsKey(key) && _lhm.get(key) != null) {
+				return _lhm.get(key);
+			} else {
+				return 0;
+			}
+		}
 	}
 
 	private EGLConfig chooseEglConfig(EGLConfig[] configs) {
@@ -448,19 +464,21 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
 		Log.d(LOG_TAG, "EGL configs:");
 
 		for (EGLConfig config : configs) {
-			EglAttribs attr = new EglAttribs(config);
+			if (config != null) {
+				EglAttribs attr = new EglAttribs(config);
 
-			// must have
-			if ((attr.get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) == 0)
-				continue;
+				// must have
+				if ((attr.get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) == 0)
+					continue;
 
-			int score = attr.weight();
+				int score = attr.weight();
 
-			Log.d(LOG_TAG, String.format(Locale.ROOT, "%s (%d)", attr.toString(), score));
+				Log.d(LOG_TAG, String.format(Locale.ROOT, "%s (%d)", attr.toString(), score));
 
-			if (score > bestScore) {
-				res = config;
-				bestScore = score;
+				if (score > bestScore) {
+					res = config;
+					bestScore = score;
+				}
 			}
 		}
 




More information about the Scummvm-git-logs mailing list