googlesamples / ios-nearby

68 stars 30 forks source link

Running the app on Xcode 9 and ios11 #29

Open prasanthhs opened 6 years ago

prasanthhs commented 6 years ago

When I run the sample code as is on a simulator running on Xcode 9 and ios11, the code crashes always with BAD_ACCESS. A sample trace is as below:

0 libdispatch.dylib 0x0000000111fbf0a2 _dispatch_continuation_async + 5 1 com.example 0x000000010b454368 0x10b418000 + 246632 2 com.example 0x000000010b452de6 0x10b418000 + 241126 3 com.example 0x000000010b4435ea 0x10b418000 + 177642 4 com.example 0x000000010b445077 0x10b418000 + 184439 5 com.example 0x000000010b442f3c 0x10b418000 + 175932 6 com.example 0x000000010b45ac20 0x10b418000 + 273440 7 com.example 0x000000010b45e6ac 0x10b418000 + 288428 8 com.example 0x000000010b45e023 0x10b418000 + 286755 9 com.example 0x000000010b45ee61 0x10b418000 + 290401 10 com.example 0x000000010b4b7f85 __76-[GSDK_GTMSessionFetcher invokeFetchCallbacksOnCallbackQueueWithData:error:]_block_invoke + 25

Any ideas?

dan-webb commented 6 years ago

I've reproduced the problem, and after investigating as much as I can, I haven't found a root cause for the crash. I see that it happens only when using BLE as a discovery medium, and that the crash happens only when running on the simulator, not on a device. And it crashes when running on the iOS 10.3 and iOS 11.1 simulators.

The Nearby Message CocoaPod was built more than a year ago, using an older version of Xcode/clang. My guess is that something in the pod is no longer compatible with the current runtime on the simulator.

I can't promise that we'll release an updated version of Nearby Messages soon, but given the seriousness of this problem, I will try to make it happen. At this point, the only workaround I know of is to run your app only on a device instead of on the simulator. Apologies for the problem it has caused you!

prasanthhs commented 6 years ago

Hi, I did check the problem a little bit.  When i make the variable "publication" and "subscription" weak, then it avoids a crash. But it then becomes a bit erratic in its behaviour (sometimes google records a message spike on the developers console, sometimes it doesn't record) and it always works only once, second time it doesn't record a message sent. So i guess it has something to do with object ownership which has changed in Xcode 9 or iOS 10? BTW One question, apart from this, does Nearby work on WIFI? Main page of your documentation says it does use Wi-FI while the iOS page says only BLE.   Regards, Prashanth On Friday, November 10, 2017, 1:33:21 AM GMT+1, Dan Webb notifications@github.com wrote:

I've reproduced the problem, and after investigating as much as I can, I haven't found a root cause for the crash. I see that it happens only when using BLE as a discovery medium, and that the crash happens only when running on the simulator, not on a device. And it crashes when running on the iOS 10.3 and iOS 11.1 simulators.

The Nearby Message CocoaPod was built more than a year ago, using an older version of Xcode/clang. My guess is that something in the pod is no longer compatible with the current runtime on the simulator.

I can't promise that we'll release an updated version of Nearby Messages soon, but given the seriousness of this problem, I will try to make it happen. At this point, the only workaround I know of is to run your app only on a device instead of on the simulator. Apologies for the problem it has caused you!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dan-webb commented 6 years ago

Hello again,

I've found the cause of the crash in our code. I have a fix for the bug, but as I mentioned before, I can't make any promises on a release date.

However, you should be aware that BLE does not work in the simulator. For some reason Apple decided not to allow it. If you restrict the set of Nearby discovery mediums to audio (instead of the default BLE and audio), you can use the simulator, and Nearby will work (as long as the volume is turned up enough on your laptop). Any testing of BLE as a discovery medium will have to be done on an actual iOS device.

Using weak references for the publications/subscriptions avoids the crash probably because the offending code is called after an RPC to the Nearby server, which doesn't complete if the pubs/subs are released soon after they're created. But I wouldn't expect Nearby to work at all in this case.

dan-webb commented 6 years ago

Regarding WiFi: Nearby on Android uses WiFi scans (along with Bluetooth and audio) to establish proximity between devices, but Nearby on iOS uses only BLE and audio (because Apple doesn't allow iOS apps to access the set of scanned WiFi networks).

maxbeech commented 6 years ago

Hi @dan-webb! Really useful info here, thanks a ton as experiencing this too. Any updates on a release date please?

Many thanks!