Android: Do Thread.sleep before loading Qt libraries in Debug Mode

Amends 269187bfa272f9456aad6a6233100d846915f175 which added the sleep
but just loading the main library.

This commit moves the delay before any library is being loaded. Also log
the fact the thread is sleeping and advertise how to use the env
QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS variable.

Fixes: QTCREATORBUG-30425
Pick-to: 6.7 6.7.0
Change-Id: Ic1370e0b9fcce8c6074f768e5d94e5aa4a0a7824
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Cristian Adam 2024-03-08 13:07:09 +01:00
parent e68c3f025e
commit 0804109d68
2 changed files with 8 additions and 4 deletions

View File

@ -136,7 +136,7 @@ class QtActivityLoader extends QtLoader {
appendApplicationParameters(getDecodedUtfString(extraAppParams)); appendApplicationParameters(getDecodedUtfString(extraAppParams));
} }
m_debuggerSleepMs = 1000; m_debuggerSleepMs = 3000;
if (Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS") != null) { if (Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS") != null) {
try { try {
m_debuggerSleepMs = Integer.parseInt(Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS")); m_debuggerSleepMs = Integer.parseInt(Os.getenv("QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS"));

View File

@ -435,6 +435,13 @@ abstract class QtLoader {
ArrayList<String> nativeLibraries = getQtLibrariesList(); ArrayList<String> nativeLibraries = getQtLibrariesList();
nativeLibraries.addAll(getLocalLibrariesList()); nativeLibraries.addAll(getLocalLibrariesList());
if (m_debuggerSleepMs > 0) {
Log.i(QtTAG, "Sleeping for " + m_debuggerSleepMs +
"ms, helping the native debugger to settle. " +
"Use the env QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS variable to change this value.");
QtNative.getQtThread().sleep(m_debuggerSleepMs);
}
if (!loadLibraries(nativeLibraries)) { if (!loadLibraries(nativeLibraries)) {
Log.e(QtTAG, "Loading Qt native libraries failed"); Log.e(QtTAG, "Loading Qt native libraries failed");
finish(); finish();
@ -511,9 +518,6 @@ abstract class QtLoader {
String mainLibPath = getLibrariesFullPaths(oneEntryArray).get(0); String mainLibPath = getLibrariesFullPaths(oneEntryArray).get(0);
final boolean[] success = {true}; final boolean[] success = {true};
QtNative.getQtThread().run(() -> { QtNative.getQtThread().run(() -> {
if (m_debuggerSleepMs > 0)
QtNative.getQtThread().sleep(m_debuggerSleepMs);
m_mainLibPath = loadLibraryHelper(mainLibPath); m_mainLibPath = loadLibraryHelper(mainLibPath);
if (m_mainLibPath == null) if (m_mainLibPath == null)
success[0] = false; success[0] = false;