1
0
Fork 0

added some debugging info around the unexplained crashes

This commit is contained in:
sspanak 2025-03-28 16:39:31 +02:00 committed by Dimo Karaivanov
parent 464e2001be
commit 5554110b7d
3 changed files with 20 additions and 1 deletions

View file

@ -1,14 +1,17 @@
package io.github.sspanak.tt9.ime;
import android.app.Dialog;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.view.Window;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import androidx.annotation.NonNull;
import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.db.DataStore;
import io.github.sspanak.tt9.db.words.DictionaryLoader;
import io.github.sspanak.tt9.hacks.InputType;
@ -240,7 +243,21 @@ public class TraditionalT9 extends MainViewHandler {
cleanUp();
isDead = true;
super.onDestroy();
// @todo: investigate the crash and remove this try-catch
try {
super.onDestroy();
} catch (Exception e) {
Dialog win = getWindow();
Window winwin = win != null ? win.getWindow() : null;
View keys = winwin != null ? winwin.findViewById(R.id.main_soft_keys) : null;
boolean hasWindowToken = keys != null && keys.getWindowToken() != null;
boolean hasAppToken = keys != null && keys.getApplicationWindowToken() != null;
String shutdownDebug = "Window token: " + hasWindowToken + "; App token: " + hasAppToken + "; main view: " + (keys != null) + "; window.window: " + (winwin != null) + "; window: " + (win != null);
throw new RuntimeException("Parent failed to destroy." + shutdownDebug);
}
Logger.d(LOG_TAG, "===> Shutdown completed");
}

View file

@ -24,6 +24,7 @@ abstract class UiHandler extends AbstractHandler {
initTray();
} else {
mainView.destroy();
setInputView(mainView.getView());
}
}

View file

@ -170,6 +170,7 @@ public class SuggestionsBar {
return suggestion;
}
// @todo: investigate the crash and remove this try-catch
try {
return stem + suggestion.substring(startIndex, endIndex);
} catch (Exception e) {