plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: connectivity_plus crashes when running on real IOS device

Open ambstuc opened this issue 3 years ago • 23 comments

Platform

IOS 16.6.1

Plugin

connectivity_plus

Version

4.0.2

Flutter SDK

3.13.5

Steps to reproduce

  1. Create new Flutter project in VS-Code ('empty flutter project'). Code attached is unchanged from the template project

  2. Run project on real IOS device (iPhone 13 pro in m case). Output:

Launching lib/main.dart on ... in debug mode... Automatically signing iOS for device deployment using specified development team in Xcode project: XXX Xcode build done. (lldb) 2023-09-21 22:53:07.512889+0100 Runner[853:88338] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend. Connecting to VM Service at ws://127.0.0.1:64855/EZy9MDloE_s=/ws

  1. install connectivity_plus (flutter pub add connectivity_plus)

  2. Re-run project. Output:

Xcode build done. (lldb) 2023-09-21 22:56:21.599196+0100 Runner[858:90229] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend. thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000000000000 error: memory read failed for 0x0 Target 0: (Runner) stopped. Error launching application on device.

Code Sample

import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello World!'),
        ),
      ),
    );
  }
}

Logs

Log too long to be attached

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.5, on macOS 13.5.2 22G91 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.1)
[✓] VS Code (version 1.82.1)
[✓] Connected device (3 available)
[✓] Network resources

Checklist before submitting a bug

  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

ambstuc avatar Sep 21 '23 22:09 ambstuc

same for me

''' @discardableResult private func ensurePathMonitor() -> NWPathMonitor { if (_pathMonitor == nil) { let pathMonitor = NWPathMonitor() // 《= Thread 1: EXC_BAD_ACCESS (code=1, address=0x0) pathMonitor.start(queue: queue) pathMonitor.pathUpdateHandler = pathUpdateHandler _pathMonitor = pathMonitor } return _pathMonitor! } '''

lvsecoto avatar Sep 22 '23 01:09 lvsecoto

Screenshot 2023-09-22 at 11 40 51 AM ![Screenshot 2023-09-22 at 11 40 51 AM (2)] Same issue

adil-nangyal avatar Sep 22 '23 06:09 adil-nangyal

image Same for me.It's quite normal last time I used it.

ganwumeng avatar Sep 22 '23 06:09 ganwumeng

https://github.com/fluttercommunity/plus_plugins/issues/2154

It's a useful way to solve this problem temporarily.

ganwumeng avatar Sep 22 '23 07:09 ganwumeng

Unfortunately, don't have real iOS device available, so can't check and fix it. Would appreciate somebody taking care of it and opening a PR.

vbuberen avatar Sep 24 '23 14:09 vbuberen

It seems 4.0.2 works on ios 17, but crashes on earlier versions.

ts-lawrence avatar Sep 25 '23 05:09 ts-lawrence

Same, only works on IOS 17

AlexeyRottCr avatar Sep 25 '23 08:09 AlexeyRottCr

App crash with iOS16.X I made the the test after upgrading to iOS17 and it works.

fvisticot avatar Sep 25 '23 12:09 fvisticot

Crashes for me as well 16.6.1

adrianvintu avatar Sep 25 '23 14:09 adrianvintu

Hi guys, I managed to fix this issue by modifying Podfile as follows: post_install do |installer| installer.pods_project.targets.each do |target| flutter_additional_ios_build_settings(target) target.build_configurations.each do |config| config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET' end end end After remove IPHONEOS_DEPLOYMENT_TARGET, all pods deploy target will be the same as main project. In my case, it's 'ios 13'. After that it works well in 16.6.1. The crash point is here: " if #available(iOS 12, *) { connectivityProvider = PathMonitorConnectivityProvider() } else { connectivityProvider = ReachabilityConnectivityProvider() }" Not quite sure about the root cause, anyone can help explain here.

ts-lawrence avatar Sep 25 '23 16:09 ts-lawrence

My code needed 2 changes, one for this plugin, one for the new Flutter version (i think)

platform :ios, '13.0'
....
post_install do |installer|
  installer.pods_project.targets.each do |target| 
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|
      #https://github.com/fluttercommunity/plus_plugins/issues/2154#issuecomment-1730330223
      config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'

      #https://stackoverflow.com/a/77134628/5734049
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
  end
end }

adrianvintu avatar Sep 25 '23 16:09 adrianvintu

+1 on iPhone SE running iOS 15.7.9 and Flutter 3.13.0

WieFel avatar Sep 27 '23 08:09 WieFel

+1 on iPhone 6s running iOS 15.7.7 and Flutter 3.13.6

The app crashes when building using Xcode 15 on my mac. When building in the CI pipeline using Xcode 14.2 and fastlane the app does not crash.

Bennik2000 avatar Sep 29 '23 11:09 Bennik2000

+1 iOS 15.5 and Flutter 3.13.6

ChargerMc avatar Sep 29 '23 13:09 ChargerMc

https://github.com/fluttercommunity/plus_plugins/issues/2154 this one worked for me

tsgofficial avatar Oct 02 '23 04:10 tsgofficial

I encourage everyone to try the fix from #2169 to let me know that I can merge and release an update for connectivity_plus.

To do so, declare the plugin the following way:

connectivity_plus:
    git:
      url: https://github.com/fluttercommunity/plus_plugins.git
      path: packages/connectivity_plus/connectivity_plus
      ref: cf7d93fbfc76830acf2db755543cf4235a49df60

UPD (Oct 3 2023): Because the PR with the fix is already merged updated the snippet to point to exact commit with the fix on main branch. Till the new version of connectivity_plus released this week, it is advised to use the version from the snippet.

vbuberen avatar Oct 02 '23 08:10 vbuberen

I encourage everyone to try the fix from #2169 to let me know that I can merge and release an update for connectivity_plus.

To do so, declare the plugin the following way:

connectivity_plus:
    git:
      url: [email protected]:fluttercommunity/plus_plugins.git
      path: packages/connectivity_plus/connectivity_plus
      ref: update/connectivity_plus_min_ios

This is working for me

but i changed url: [email protected]:fluttercommunity/plus_plugins.git to https://github.com/fluttercommunity/plus_plugins.git to be able to download it

byjoker8625 avatar Oct 02 '23 09:10 byjoker8625

Thank you very much for your feedback and for the fix of the link. I will merge the PR and will try to release updates for plugins this week.

vbuberen avatar Oct 02 '23 10:10 vbuberen

when do you update new version? @vbuberen

nambui2000k avatar Oct 02 '23 13:10 nambui2000k

Read the message above

vbuberen avatar Oct 02 '23 13:10 vbuberen