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

Android app 'pause' or 'screen-off' causes 'eglSwapBuffers failed' and various logcat errors

    XMLWordPrintable

Details

    • Android
    • 0f20feea2 (dev), e5513a944 (dev), 9343d1ab6 (dev), 6eb29cab2 (6.8), 868324d1e (6.8), 1215f61a1 (6.8), 7a9af281d (tqtc/lts-5.15), 4d3cc29fd (tqtc/lts-5.15), a33cf4c27 (tqtc/lts-6.5), 1b2b4ecd1 (tqtc/lts-6.5)
    • 2023wk44FOQtforAndroid, 2023wk46FOQtforAndroid, 2023wk48FOQtforAndroid, 2023wk50FOQtforAndroid, 2023wk52FOQtforAndroid, 2024wk14FOQtforAndroid, 2024wk16FOQtforAndroid, 2024wk46s3FOQtforAndroid, 2024wk48s3FOQtforAndroid

    Description

      When a Qt QML app on Android is paused (sent to the background), or the device screen turned off, the following QML warning is often reported:

      "QEGLPlatformContext: eglSwapBuffers failed: 300d"

      In addition, a number of errors and warnings are written to the Android logcat output, apparently related to the management and synchronization of drawing surfaces and/or OpenGL buffers.

      To reproduce this, simply build and run the "emitters" example app (C:\Qt\Examples\Qt-5.15.14\quick\particles\emitters), and then choose the "Custom Emitters" option, which shows a continuous animation. In fact, any QML app that does frequent screen updates will likely work, but this is the example app I've been testing with. The device I'm testing on is:

      • Google Pixel 5 phone
      • Android 13 OS

      ...but I believe any Android device will produce similar (but not identical) errors.

      Build and run the app while debugging from within Qt Creator. When another app is  brought to front (causing an Android 'paused' event for the emitters app), there is flood of warnings and errors. Here is a small subset of the errors and warnings I'm seeing:

      E OpenGLRenderer: Unable to match the desired swap behavior.
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#31(BLAST Consumer)31](id:66d60000001f,api:0,p:-1,c:26326) requestBuffer: BufferQueue has no connected producer
      E Surface : dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -19
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#31(BLAST Consumer)31](id:66d60000001f,api:0,p:-1,c:26326) cancelBuffer: BufferQueue has no connected producer
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#31(BLAST Consumer)31](id:66d60000001f,api:0,p:-1,c:26326) dequeueBuffer: BufferQueue has no connected producer
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      W libemitters_arm64-v8a: QEGLPlatformContext: eglSwapBuffers failed: 300d 

      If the emitters app is in the foreground, and the device screen is turned off, a slightly different set of errors and warnings occur:

      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#34(BLAST Consumer)34](id:66d600000022,api:0,p:-1,c:26326) dequeueBuffer: BufferQueue has no connected producer
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#34(BLAST Consumer)34](id:66d600000022,api:0,p:-1,c:26326) dequeueBuffer: BufferQueue has no connected producer
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      W libemitters_arm64-v8a: QEGLPlatformContext: eglSwapBuffers failed: 300d
      E BufferQueueProducer: [SurfaceView[org.qtproject.example.emitters/org.qtproject.qt5.android.bindings.QtActivity]#34(BLAST Consumer)34](id:66d600000022,api:0,p:-1,c:26326) disconnect: not connected (req=1)
      W libEGL  : EGLNativeWindowType 0x7398d64af0 disconnect failed 

      On another device - a Trimble TDC600 Model 2 running Android 10 - there are much fewer errors, especially on a "pause". Pausing the app (switching to another app) results in just this warning:

      W libEGL  : EGLNativeWindowType 0x7301f72010 disconnect failed 

      while turning the screen off results in these errors and warnings:

      E Surface : dequeueBuffer: IGraphicBufferProducer::requestBuffer failed: -19
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      W libemitters_arm64-v8a: QEGLPlatformContext: eglSwapBuffers failed: 300d
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      I Adreno  : DequeueBuffer: dequeueBuffer failed
      W libemitters_arm64-v8a: QEGLPlatformContext: eglSwapBuffers failed: 300d

      While these errors and warnings are not necessarily harmful in and of themselves, they do seem to indicate problems with the implementation - it would appear that Qt is not doing a very good job of synchronizing the 'pause' and 'resume' events in relation to its SurfaceView drawing, or its management of OpenGL buffers.

      Aside from the annoyance factor of these errors and warnings, the problems described here may be having a much more serious impact on our application, Trimble Access. With Trimble Access on a TDC600 Model 2, turning the screen off can sometimes cause the app to crash. When this happens, we always see the "eglSwapBuffers failed" warning, and in addition, we get "gpu fault" errors recorded in the Android bug report:

      <2>[12903.219365] kgsl kgsl-3d0: |adreno_hang_int_callback| MISC: GPU hang detected
      <3>[12903.219449] kgsl kgsl-3d0: .trimble.access[7719]: gpu fault ctx 12 ctx_type GL ts 4110594 status E01801C5 rb 0400/04c0 ib1 00000007FF56B0F0/0b14 ib2 00000007FF450374/0184
      <3>[12903.219452] kgsl kgsl-3d0: .trimble.access[7719]: gpu fault rb 2 rb sw r/w 0400/04c0
      <3>[12903.320058] kgsl: adreno_snapshot: GPU snapshot froze 152Kb of GPU buffers
      <3>[12903.320069] kgsl kgsl-3d0: |kgsl_device_snapshot| snapshot created at pa 0x00000000ea000000 size 843500
      <2>[12903.333818] kgsl kgsl-3d0: |adreno_hang_int_callback| MISC: GPU hang detected
      <3>[12903.334358] kgsl kgsl-3d0: .trimble.access[7719]: gpu failed ctx 12 ts 4110595  

      While I don't have definitive proof that these GPU faults, and resulting app crashes, are a consequence of the warnings and errors described above, circumstantially this seems very likely.

      So - to be clear - we have an intermittent crash in our app, Trimble Access, that I believe may be related to these warnings and errors. However, I have not been able to reproduce these crashes using a Qt sample app. The warnings and errors themselves, as described above, are however easily reproducible. My hope is that something can be done to resolve the various warnings and errors described in this bug report; and then, if we're lucky, we might find that this also resolves the intermittent crashes we're seeing in Trimble Access.

      Attachments

        Issue Links

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

          Activity

            People

              bartlomiejmoskal Bartlomiej Moskal
              roballan Rob Allan
              Votes:
              3 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: