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.0
Change-Id: Ic1370e0b9fcce8c6074f768e5d94e5aa4a0a7824
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 0804109d686e0a99ab0de0f1c70e3422183c6e98)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Cristian Adam 2024-03-08 13:07:09 +01:00 committed by Qt Cherry-pick Bot
parent fdcebd63cd
commit 1fb2c58ef3
2 changed files with 8 additions and 4 deletions

View File

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

View File

@ -435,6 +435,13 @@ public abstract class QtLoader {
ArrayList<String> nativeLibraries = getQtLibrariesList();
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)) {
Log.e(QtTAG, "Loading Qt native libraries failed");
finish();
@ -511,9 +518,6 @@ public abstract class QtLoader {
String mainLibPath = getLibrariesFullPaths(oneEntryArray).get(0);
final boolean[] success = {true};
QtNative.getQtThread().run(() -> {
if (m_debuggerSleepMs > 0)
QtNative.getQtThread().sleep(m_debuggerSleepMs);
m_mainLibPath = loadLibraryHelper(mainLibPath);
if (m_mainLibPath == null)
success[0] = false;