Disable viewport height for GitHub version

pull/217/head
M66B 8 months ago
parent 9059225a86
commit b12e2f89fb

@ -159,6 +159,25 @@ public class ApplicationEx extends Application
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override @Override
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) { public void uncaughtException(@NonNull Thread thread, @NonNull Throwable ex) {
// java.lang.IllegalStateException: Unable to create layer for WebViewEx, size 768x4864 max size 8192 color type 4 has context 1
// at android.os.MessageQueue.nativePollOnce(MessageQueue.java:-2)
// at android.os.MessageQueue.next(MessageQueue.java:326)
// at android.os.Looper.loop(Looper.java:183)
// at android.app.ActivityThread.main(ActivityThread.java:7266)
if (ex instanceof IllegalStateException &&
ex.getMessage() != null &&
ex.getMessage().contains("Unable to create layer for WebView")) {
int viewport_height = prefs.getInt("viewport_height", WebViewEx.DEFAULT_VIEWPORT_HEIGHT);
if (viewport_height > WebViewEx.DEFAULT_VIEWPORT_HEIGHT) {
prefs.edit().putInt("viewport_height", WebViewEx.DEFAULT_VIEWPORT_HEIGHT).apply();
Log.setCrashReporting(true);
Log.e(ex);
System.exit(1);
return;
}
}
if (!crash_reports && Log.isOwnFault(ex)) { if (!crash_reports && Log.isOwnFault(ex)) {
Log.e(ex); Log.e(ex);

@ -280,8 +280,12 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// Unable to create layer for WebViewEx, size 1088x16384 max size 16383 color type 4 has context 1) // Unable to create layer for WebViewEx, size 1088x16384 max size 16383 color type 4 has context 1)
int limitHeight = MeasureSpec.makeMeasureSpec(viewportHeight, MeasureSpec.AT_MOST); if (viewportHeight == 0)
super.onMeasure(widthMeasureSpec, limitHeight); heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
else
heightMeasureSpec = MeasureSpec.makeMeasureSpec(viewportHeight, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int mh = getMeasuredHeight(); int mh = getMeasuredHeight();
Log.i("Measured height=" + mh + " last=" + height + "/" + maxHeight + " ch=" + getContentHeight()); Log.i("Measured height=" + mh + " last=" + height + "/" + maxHeight + " ch=" + getContentHeight());
@ -477,6 +481,9 @@ public class WebViewEx extends WebView implements DownloadListener, View.OnLongC
} }
static int getDefaultViewportHeight(Context context) { static int getDefaultViewportHeight(Context context) {
if (!Helper.isPlayStoreInstall())
return 0;
if (Helper.isGoogle() && Build.VERSION.SDK_INT > Build.VERSION_CODES.UPSIDE_DOWN_CAKE /* Android 14 */) if (Helper.isGoogle() && Build.VERSION.SDK_INT > Build.VERSION_CODES.UPSIDE_DOWN_CAKE /* Android 14 */)
return DEFAULT_VIEWPORT_HEIGHT * 2; return DEFAULT_VIEWPORT_HEIGHT * 2;
else else

Loading…
Cancel
Save