Yukams / background_locator_fixed

A Flutter plugin for updating location in background.
MIT License
50 stars 103 forks source link

Crash loop on iPhone at app start (EXC_BAD_ACCESS - KERN_INVALID_ADDRESS) #62

Open oguzyildizz opened 1 year ago

oguzyildizz commented 1 year ago

Hi, thank you for fixing the original repo and creating this fork.

I'm having issues with this plugin though: The app works fine at first (when I run flutter run or just run the app through Xcode), but if I terminate the app and start it again, it crashes immediately, and it keeps doing that until I reinstall the app. I looked at the device logs and if I'm understanding it correctly, it's coming from one of the lines we add in the Setup:

Notes:

I'm new to mobile app developing, and google'd everything I could, yet couldn't find anything helpful. I'd appreciate any help.

Thanks in advance!

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes: 0x0000000000000001, 0x0000000000000000
VM Region Info: 0 is not in any region.  Bytes before following region: 4364288000
      REGION TYPE                 START - END      [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                   10421c000-1052cc000 [ 16.7M] r-x/r-x SM=COW  ...er.app/Runner
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [767]

Triggered by Thread:  0

Crashed: com.apple.main-thread
0  ???                            0x1852576f4 (Missing)
...
4  ???                            0x104e16f80 (Missing)
5  Runner                         0x6780 +[GeneratedPluginRegistrant registerWithRegistry:] + 171 (GeneratedPluginRegistrant.m:171)
6  Runner                         0x6e94 AppDelegate.application(_:didFinishLaunchingWithOptions:) + 23 (AppDelegate.swift:23)
7  Runner                         0x71ac @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) (<compiler-generated>)
8  ???                            0x182c27044 (Missing)
...
42 ???                            0x182b967f4 (Missing)
43 Runner                         0x7578 main + 15 (AppDelegate.swift:15)
44 ???                            0x104345a24 (Missing)

Here's my AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps
import background_locator_2
import Firebase
import FirebaseAuth

func registerPlugins(registry: FlutterPluginRegistry) -> () {
    if (!registry.hasPlugin("BackgroundLocatorPlugin")) {
        GeneratedPluginRegistrant.register(with: registry)
    }
}

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { 
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      FirebaseApp.configure()
      GMSServices.provideAPIKey("...")

      GeneratedPluginRegistrant.register(with: self)
      BackgroundLocatorPlugin.setPluginRegistrantCallback(registerPlugins)

      return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}

    override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        let firebaseAuth = Auth.auth()
        firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
    }

}
Yukams commented 1 year ago

Hi, is this still a problem ?