Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83475

QtAndroid::runOnAndroidThread does not respect background_running

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 5.15
    • 5.12.8
    • Extras: Android
    • None
    • Android

    Description

      When an Android application is set to allow the QtEvent loop to run while the application is in the suspended state, calling QtAndroid::runOnAndroidThread events get queued and calling QtAndroid::runOnAndroidThreadSync will in turn cause Qt's main thread to then be blocked.

       

      In the below code snippet, it is queueing based solely on if the activity is paused, I believe it should also check for the background_running value set in the Android manifest as well.

       private static void runPendingCppRunnablesOnAndroidThread()
          {
              synchronized (m_mainActivityMutex) {
                  if (m_activity != null) {
                      if (!m_activityPaused)
                          m_activity.runOnUiThread(runPendingCppRunnablesRunnable);
                      else
                          runAction(runPendingCppRunnablesRunnable);
                  } else {
                      final Looper mainLooper = Looper.getMainLooper();
                      final Thread looperThread = mainLooper.getThread();
                      if (looperThread.equals(Thread.currentThread())) {
                          runPendingCppRunnablesRunnable.run();
                      } else {
                          final Handler handler = new Handler(mainLooper);
                          handler.post(runPendingCppRunnablesRunnable);
                      }
                  }
              }
          }

       

      Attachments

        For Gerrit Dashboard: QTBUG-83475
        # Subject Branch Project Status CR V

        Activity

          People

            mike12779 Michael Dippold
            mike12779 Michael Dippold
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change