Skip to content

Navigation: Channel communication fails on iOS when integrating Turn-by-Turn navigation into a larger app #211

@yehuda-noiman

Description

@yehuda-noiman

Environment details

  1. Flutter version 3.24.3, stable channel
  2. sonama 14.5, intel
  3. google_navigation_flutter: ^0.3.0
    OS type and version: iOS iOS 16.7.10 but reproduced at any IOS we tried
    Library version and other environment information:
    Flutter version: 3.22.1 • channel stable
    google_navigation_flutter version: 0.3.0

Device model: (IPhone 8 plus, iPhone 12 Pro Max, more IOS devices)
Steps to reproduce
Integrate the google_navigation_flutter plugin into a large existing Flutter app.
Implement the Turn-by-Turn navigation feature using code from the example app.
Run the app on an iOS device or simulator.
Attempt to start Turn-by-Turn navigation.
Observe that the app fails due to channel communication issues.
Expected behavior
The Turn-by-Turn navigation should start and function as expected, just like it does in the example app provided by the google_navigation_flutter plugin.
Actual behavior
When attempting to start Turn-by-Turn navigation in the larger app, the app fails on channel communication. Specifically, the response in the onNavInfo function is nil, leading to a failure in the completion handler.
from messages.g.swift
/// Turn-by-Turn navigation events.

func onNavInfo(navInfo navInfoArg: NavInfoDto,
               completion: @escaping (Result<Void, FlutterError>) -> Void) {
    let channelName =
      "dev.flutter.pigeon.google_navigation_flutter.NavigationSessionEventApi.onNavInfo"
    let channel = FlutterBasicMessageChannel(
      name: channelName,
      binaryMessenger: binaryMessenger,
      codec: codec
    )
    channel.sendMessage([navInfoArg] as [Any?]) { response in
        guard let listResponse = response as? [Any?] else {
            // The code goes here and the response is nil
            completion(.failure(createConnectionError(withChannelName: channelName)))
            return
        }
        if listResponse.count > 1 {
            let code: String = listResponse[0] as! String
            let message: String? = nilOrValue(listResponse[1])
            let details: String? = nilOrValue(listResponse[2])
            completion(.failure(FlutterError(code: code, message: message, details: details)))
        } else {
            completion(.success(()))
        }
    }
}

Note: The comment // The code goes here and the response is nil indicates where the response is unexpectedly nil.
Note2: The simulator works it's just that we don't get any events on the dart side

Additional Information:
The Turn-by-Turn navigation works as expected when using the example app provided by the plugin.
The issue only occurs when integrating the same code into a larger app.
There might be a discrepancy in how the message channels are set up or how the binary messenger communicates in a larger app context.
Please let me know if you'd like to add anything else or need further assistance!

Metadata

Metadata

Labels

priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions