Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: App Crashes while navigating #4715

Open
JanTG1 opened this issue Sep 1, 2024 · 2 comments
Open

[Bug]: App Crashes while navigating #4715

JanTG1 opened this issue Sep 1, 2024 · 2 comments
Labels
bug Something isn’t working

Comments

@JanTG1
Copy link

JanTG1 commented Sep 1, 2024

Mapbox Navigation SDK version

3.3.0-beta.1

Steps to reproduce

Start a Navigation Session and drive around for 15-20 minutes, following the guidance.

Expected behavior

Nothing. Active guidance continues and the app does not run into any issues.

Actual behavior

The app crashes abruptly, without giving me the ability to send a crash report through testflight. I tested three times on different routes.

  • First Route was expected to take around 30 minutes. I followed the guidance without any issues for about 15 Minutes. After exactly 17 Minutes and 47 Seconds, the App crashed suddenly without having any noticeable issue before crashing. Even though I ran the app through testflight, I got no prompt to send a crash report.
  • Second Route was expected to take around 17 Minutes. I followed the guidance, and arrived at my destination after 16 Mins and 30 secs, the app did not crash.
  • Third Route was expected to take around 30 minutes. I followed the guidance like always, but the app then crashed just like on route 1 after exactly 15 minutes and 36 seconds. Again, no crash report dialog.

I checked my own device logs through our own support system but could not find anything indicating an error from any backend calls or anything similar. After a quick google search I found out that if the App does not show you a crash report dialog after crashing, the device might have killed the process due to a memory issue, which is not regarded as a crash, since the app is knowingly killed by the OS. (Source: https://stackoverflow.com/questions/76667789/testflight-does-not-showing-crash-log-for-specific-beta-tester). This would indicate that the memory filled up to a point where the OS Killed the app. I tested it on an iPhone 15 Pro.
When testing again at home using the xCode Memory Report, I found that moving the camera around during active guidance does increase memory use. However, since I am not driving around, I can only simulate. The Memory use stagnates between 800mb and 1,2 GB (15%) but I don't have any reroute events or similar, since I am stationary. Even after 20 minutes of moving the camera, the memory usage did not far exceed 1,2 GB. I cannot say for sure that it is a memory issue, it's just a guess based on the missing dialog after crashing.

Is this a one-time issue or a repeatable issue?

repeatable

@JanTG1 JanTG1 added the bug Something isn’t working label Sep 1, 2024
@JanTG1
Copy link
Author

JanTG1 commented Sep 3, 2024

There are updates on this:

I have tested by driving around for over half an hour while hooked up to xCode over my Mac (lol). I was hoping to catch the crash because crash logs were not helping or missing altogether. But it did not crash and because I was feeling stupid doing so, I gave up.

Today while working on another issue and testing while being hooked up to the debugger, the app crashed a few seconds after launching the navigation. The only few things I could read from the few crash logs I had was that it had something to do with the RouteProgress, and that it was an EXC_BAD_ACCESS crash, meaning that something was probably read while being out of memory. Todays crash looks to be exactly that, an EXC_BAD_ACCESS crash on the RouteProgess Extension:

MapboxNavigation>Sources>MApboxNavigationCore>Map>Style>IntersectionAnnotationsMapFeatures>intersectionAnnotationsMapFeatures(ids:customizedLayerProvider:)

extension RouteProgress {
    func intersectionAnnotationsMapFeatures(
        ids: FeatureIds.IntersectionAnnotation,
        customizedLayerProvider: CustomizedLayerProvider
    ) -> [any MapFeature] {
        guard !routeIsComplete else {
            return []
        }

        var featureCollection = FeatureCollection(features: [])

        let stepProgress = currentLegProgress.currentStepProgress
        let intersectionIndex = stepProgress.intersectionIndex
        let stepIntersections = stepProgress.intersectionsIncludingUpcomingManeuverIntersection

        for intersection in stepIntersections?.dropFirst(intersectionIndex) ?? [] { //CRASHES HERE!
            if let feature = intersectionFeature(from: intersection, ids: ids) {
                featureCollection.features.append(feature)
            }
        }

        let layers: [any Layer] = [
            with(SymbolLayer(id: ids.layer, source: ids.source)) {
                $0.iconAllowOverlap = .constant(false)
                $0.iconImage = .expression(Exp(.get) {
                    "imageName"
                })
            },
        ]
        return [
            GeoJsonMapFeature(
                id: ids.featureId,
                sources: [
                    .init(
                        id: ids.source,
                        geoJson: .featureCollection(featureCollection)
                    ),
                ],
                customizeSource: { _, _ in },
                layers: layers.map { customizedLayerProvider.customizedLayer($0) },
                onBeforeAdd: { mapView in
                    Self.upsertIntersectionSymbolImages(
                        map: mapView.mapboxMap,
                        ids: ids
                    )
                },
                onUpdate: { mapView in
                    Self.upsertIntersectionSymbolImages(
                        map: mapView.mapboxMap,
                        ids: ids
                    )
                },
                onAfterRemove: { mapView in
                    do {
                        try Self.removeIntersectionSymbolImages(
                            map: mapView.mapboxMap,
                            ids: ids
                        )
                    } catch {
                        Log.error(
                            "Failed to remove intersection annotation images with error \(error)",
                            category: .navigationUI
                        )
                    }
                }
            ),
        ]
    }
[...]

It crashed on line 21: for intersection in stepIntersections?.dropFirst(intersectionIndex) ?? [] {

Please handle this urgently because it makes my app unusable at the moment. Also, I have updated to the newest release 3.3.1 from yesterday. It seems like the new release did not change anything on this matter.

@kried
Copy link
Contributor

kried commented Sep 19, 2024

Hi @JanTG1

Thank you for the report.
We are investigating memory usage in the SDK.
Regarding the stepIntersections?.dropFirst(intersectionIndex) please wait for v3.4.0-rc.1 release where we change the usage of stepIntersections a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

No branches or pull requests

2 participants