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

Possible deadlock while starting an Android service

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.2.0 FF
    • Core: Other, QPA: Android
    • None
    • Android
    • 2023wkXXFOQtforAndroid

    Description

      I've figured out that if I want to check the permissions directly from the main() function of the Android Service, it gets stuck. The same approach works well for the normal Activity.

      Some investigation shows that there might be a deadlock in QtNative.java.

      A QCoreApplication::checkPermission() call results in a call to checkSelfPermission() in QtNative.java. It attempts to lock the m_mainActivityMutex, which seems to be still locked by a call to startApplication().

      The straightforward solution is to run the QCoreApplication::checkPermission() from a QTimer::singleShot(), that will put it on the event loop.

       

      I'm attaching a small example that reproduces the problem.

      Attachments

        Issue Links

          Activity

            People

              qtandroidteam Qt Android Team
              ivan.solovev Ivan Solovev
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: