CocoaMQTT icon indicating copy to clipboard operation
CocoaMQTT copied to clipboard

Crash when build by Xcode 14.0 beta 5 (14A5294e) and run on iOS 16.0 (20A5339d)

Open taolunyifan opened this issue 1 year ago • 30 comments

image

image

taolunyifan avatar Aug 15 '22 08:08 taolunyifan

We have a very similar problem with our project.

markusgrape avatar Aug 16 '22 13:08 markusgrape

Hi, bro @markusgrape . Do you have a way to reproduce this issue?

leeway1208 avatar Aug 16 '22 13:08 leeway1208

@leeway1208 In my project it happens during establishing connection with a MQTT broker.

jojo0899 avatar Aug 16 '22 13:08 jojo0899

@leeway1208 the crash seems to come directly after we connect to MQTT broker when using xcode 14.0 beta 5. The stacktrace looks very similar to the image above.

CocoaMQTT(info): Connected to x.x.x.x : 8083 CocoaMQTT(info): Enable backgrounding socket successfully (lldb) <- Crash

markusgrape avatar Aug 16 '22 13:08 markusgrape

@markusgrape Will the demo report crash either? I can't reproduce it yet, hope you can help me. Thanks~~

leeway1208 avatar Aug 16 '22 13:08 leeway1208

Same crash here. Running iPad OS beta 5 and Xcode beta 3.

iPadOS beta 3 is fine though.

tonydavidcray avatar Aug 17 '22 00:08 tonydavidcray

@leeway1208 are you using Xcode beta 5/iOS 16 device? it is 100% reproducible for me when using that, every time it connects to MQTT broker there is this crash.

markusgrape avatar Aug 17 '22 06:08 markusgrape

Needs to be an issue with iOS 16. Using Xcode beta 5 with iPadOS 15 works fine.

jojo0899 avatar Aug 17 '22 07:08 jojo0899

@jojo0899 Not sure about this, we tested building with xcode 13 and iOS16 device without issues.

markusgrape avatar Aug 17 '22 07:08 markusgrape

I find simulator can not reproduce so far. It seems to be caused by the real IOS devices.

leeway1208 avatar Aug 17 '22 09:08 leeway1208

We have the same issue. It works fine on iOS 16 simulators, but not on a real iOS device. Using Xcode 14 beta 5 and iOS 16.0 public beta (20A5349b).

When using Xcode 14 beta 5 with iOS 15 on a real device, it works fine though.

StevenVerheyen avatar Aug 17 '22 11:08 StevenVerheyen

I'm experiencing the exact same crash, and I tested with different configurations using the example project in this repo. It only happens with Xcode 14 beta 5 and iOS 16.0 public beta (20A5349b) on a real device. I haven't seen the crash for the following configurations.

  • Xcode 14 beta 5 and iOS 16 simulator
  • Xcode 14 beta 5 and iOS 15.5 device
  • Xcode 14 beta 5 and MacBook with M1 pro chip
  • Xcode 13.4.1 and iOS 16.0 public beta device
  • Xcode 13.4.1 and iOS 15.5 simulator
  • Xcode 13.4.1 and iOS 15.6 device
  • Xcode 13.4.1 and MacBook with M1 pro chip

ridvankotan avatar Aug 18 '22 07:08 ridvankotan

@ridvankotan thanks for your support

leeway1208 avatar Aug 18 '22 09:08 leeway1208

@leeway1208 any update on this?

markusgrape avatar Aug 24 '22 11:08 markusgrape

Hi. We are working on it. Will get back to you soon.

leeway1208 avatar Aug 24 '22 13:08 leeway1208

I wonder has the the recently released beta 7 had any impact on this ? And now beta 8?

tonydavidcray avatar Aug 27 '22 22:08 tonydavidcray

I tested with the latest iOS 16 beta 7 and Xcode beta, and we still have the same crash.

ridvankotan avatar Aug 29 '22 07:08 ridvankotan

Any update on this? Thanks in advance.

karolis1993 avatar Sep 07 '22 08:09 karolis1993

I just tested this patch https://github.com/robbiehanson/CocoaAsyncSocket/pull/802/files manually on CocoaAsyncSocket and it solved this crash for me, hopefully there is an official release soon.

markusgrape avatar Sep 08 '22 12:09 markusgrape

I can confirm that the above mentioned patch works.

kubbing avatar Sep 08 '22 12:09 kubbing

waiting for the fix, the crash is reproducible on Xcode 14, stable release for CocoaMQTT 2.0.5

niralishaha25 avatar Sep 14 '22 12:09 niralishaha25

I also confirm that mentioned patch of CocoaAsyncSocket solves the issue. As the CocoaAsyncSocket project seems to be dead, are there any plans on dropping this dependency? As now CocoaMQTT is basically unusable on iOS 16 solely due to this issue.

jupe1 avatar Sep 14 '22 13:09 jupe1

Same issue:

  • Xcode 14
  • iOS 16
  • CocoaMQTT 2.0.5

The crash happens here (line 3052 GCDAsyncSocket didConnect):

[theDelegate socket:self didConnectToHost:host port:port];

riccardoch avatar Sep 14 '22 13:09 riccardoch

I just tested this patch https://github.com/robbiehanson/CocoaAsyncSocket/pull/802/files manually on CocoaAsyncSocket and it solved this crash for me, hopefully there is an official release soon.

I can confirm the crash is solved changing kCFStreamNetworkServiceType from kCFStreamNetworkServiceTypeVoIP to kCFStreamNetworkServiceTypeBackground

riccardoch avatar Sep 14 '22 13:09 riccardoch

Crash happen because CocoaAsyncSocket 7.6.5 still use kCFStreamNetworkServiceTypeVoIP. To See This CocoaAsyncSocket doesn't update, you can fix it by change code yourself.

Add #import to GCDAsyncSocket.m #import <PushKit/PushKit.h>

Replace in enableBackgroundingOnSocketWithCaveat r1 = CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, PKPushTypeVoIP); r2 = CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, PKPushTypeVoIP);

Also, you disable backgroundOnSocket to false, but it's not well.

seasonZhu avatar Sep 15 '22 09:09 seasonZhu

@seasonZhu Run OK, thank you, the backgroundOnSocket is normal

samson7s avatar Sep 18 '22 14:09 samson7s

@seasonZhu Run OK, thank you, the backgroundOnSocket is normal

samson7s avatar Sep 18 '22 14:09 samson7s

Same here...

tomerpetel avatar Sep 19 '22 07:09 tomerpetel

Any update on when there will be an official fix?

StevenVerheyen avatar Sep 22 '22 07:09 StevenVerheyen

Any update on when there will be an official fix?

I tried to fix it yesterday. You can update the latest version.

leeway1208 avatar Sep 22 '22 14:09 leeway1208