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

didReceiveWriteRequests during addConnectedCentral

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.3
    • None
    • iOS/tvOS/watchOS

    Description

      Hi i have a Critical race conditions on iOS bluetooth peripheral.
      This is the scenario. I have my app that acts like a peripheral. Everything works fine, the central side read and write data continuosly.
      When a disconnection happen, it can occurs this race:

      • central disconnects itself
      • my app get it and start to advertise again
      • central sees the advertisment and try to connect to it immediately
      • connection restabilished, but i had a crash sometimes, check this backtrace
      Thread 6 name:
      Thread 6 Crashed:
      0   libobjc.A.dylib               	0x0000000196208110 objc_msgSend + 48
      1   app                          	0x0000000102eb1548 0x102c4c000 + 2512200 addCharacteristicsAndDescriptors
      2   app                                 0x0000000102eaff90 0x102c4c000 + 2506640 didReceiveWriteRequests 
      3   app                                 0x0000000102eb07e8 0x102c4c000 + 2508776 addConnectedCentral
      4   libdispatch.dylib             	0x0000000180de424c _dispatch_call_block_and_release + 32 (init.c:1454)
      5   libdispatch.dylib             	0x0000000180de5db0 _dispatch_client_callout + 20 (object.m:559)
      6   libdispatch.dylib             	0x0000000180ded10c _dispatch_lane_serial_drain + 580 (inline_internal.h:2548)
      7   libdispatch.dylib             	0x0000000180dedc5c _dispatch_lane_invoke + 408 (queue.c:3862)
      8   libdispatch.dylib             	0x0000000180df7d78 _dispatch_workloop_worker_thread + 708 (queue.c:6601)
      9   libsystem_pthread.dylib       	0x00000001ccca1814 _pthread_wqthread + 276 (pthread.c:2210)
      10  libsystem_pthread.dylib       	0x00000001ccca876c start_wqthread + 8
      

      The strange thing, is that when a peripheral qt app on iOS disconnects from the central side, there is no need to put again the services: infact, if you did, you will have dupliace services.
      This is my reconnect code

       

      void v::reconnect()
      { 
         qDebug() << "v::reconnect"; 
         leController->disconnectFromDevice(); 
      #ifndef Q_OS_IOS 
          service = leController->addService(serviceData); 
      #endif 
          QLowEnergyAdvertisingParameters pars; 
          pars.setInterval(100, 100); 
          leController->startAdvertising(pars, advertisingData, advertisingData); 
      }
      

       

      as you can see i removed the addService from the iOS build because it caused duplicate services.

      What do you think ablasche tpochep ?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tpochep Timur Pocheptsov
            robertoviola Roberto Viola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes