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

Native (OpenGL related?) crash when leaving navigation screen #675

Closed
briandilley opened this issue Jan 28, 2018 · 11 comments
Closed

Native (OpenGL related?) crash when leaving navigation screen #675

briandilley opened this issue Jan 28, 2018 · 11 comments

Comments

@briandilley
Copy link

I get the following crash when leaving the navigation view (sometimes). I can't seem to be able to tie it to a specific series of events, it just sometimes happens. I'm using the navigation view in a fragment.

Device: Google Pixel 2
OS Version: 8.1.0
library versions:

    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.3.2'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.9.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-traffic:0.3.0'
    implementation('com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.9.0') {
        transitive = true
    }
01-28 14:28:34.676 24698 24698 D QR/BaseFragment: onStop(185125091)
01-28 14:28:34.676 24698 24698 D QR/BaseFragment: onDestroyView(185125091)
01-28 14:28:34.696 24698 24698 W TextToSpeech: stop failed: not bound to TTS engine
01-28 14:28:34.696 24698 24698 W TextToSpeech: shutdown failed: not bound to TTS engine
01-28 14:28:34.698 24698 25254 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 25254 (GLThread 55395), pid 24698 (kride.DriverApp)
01-28 14:28:34.726 24698 25156 D QR/DriverUpdatesWS: onClosed(240575796,1000,Closing)
01-28 14:28:34.777 25263 25263 I crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
01-28 14:28:34.778   865   865 I /system/bin/tombstoned: received crash request for pid 24698
01-28 14:28:34.780 25263 25263 I crash_dump64: performing dump of process 24698 (target tid = 25254)
01-28 14:28:34.781 25263 25263 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-28 14:28:34.781 25263 25263 F DEBUG   : Build fingerprint: 'google/walleye/walleye:8.1.0/OPM1.171019.013/4474084:user/release-keys'
01-28 14:28:34.781 25263 25263 F DEBUG   : Revision: 'MP1'
01-28 14:28:34.781 25263 25263 F DEBUG   : ABI: 'arm64'
01-28 14:28:34.781 25263 25263 F DEBUG   : pid: 24698, tid: 25254, name: GLThread 55395  >>> com.gosuna.quickride.DriverApp <<<
01-28 14:28:34.781 25263 25263 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
01-28 14:28:34.781 25263 25263 F DEBUG   : Cause: null pointer dereference
01-28 14:28:34.781 25263 25263 F DEBUG   :     x0   0000000000000000  x1   0000007ce46f4518  x2   0000000000000001  x3   0000007d09d3e17a
01-28 14:28:34.781 25263 25263 F DEBUG   :     x4   0000007cedbf3fc0  x5   0000008000000080  x6   00ffffffffffffff  x7   ffffffffffffffff
01-28 14:28:34.781 25263 25263 F DEBUG   :     x8   0000000000000000  x9   0000000000000001  x10  0000007cedbf54f0  x11  0000000000000000
01-28 14:28:34.781 25263 25263 F DEBUG   :     x12  0000000000000000  x13  ffffffffffffff00  x14  0000007cedbf4118  x15  0000000000000000
01-28 14:28:34.781 25263 25263 F DEBUG   :     x16  0000007cf26287a8  x17  0000007d8dd33598  x18  000000000000013c  x19  0000007ce46f4500
01-28 14:28:34.781 25263 25263 F DEBUG   :     x20  0000007cf3f89d00  x21  0000007ce46f4518  x22  0000007cf3f89dd8  x23  0000007cedbf5588
01-28 14:28:34.781 25263 25263 F DEBUG   :     x24  0000000000000004  x25  0000007cedbf5588  x26  0000007ceb6156a0  x27  0000000000000001
01-28 14:28:34.781 25263 25263 F DEBUG   :     x28  0000007cedbf4120  x29  0000007cedbf4090  x30  0000007cf2099e98
01-28 14:28:34.781 25263 25263 F DEBUG   :     sp   0000007cedbf4020  pc   0000007cf225c9dc  pstate 0000000080000000
01-28 14:28:34.791 25263 25263 F DEBUG   :
01-28 14:28:34.791 25263 25263 F DEBUG   : backtrace:
01-28 14:28:34.791 25263 25263 F DEBUG   :     #00 pc 00000000002759dc  /data/app/com.gosuna.quickride.DriverApp-TbALx_qfr2LZZ3tQHO5-aw==/lib/arm64/libmapbox-gl.so
01-28 14:28:34.791 25263 25263 F DEBUG   :     #01 pc 00000000000b2e94  /data/app/com.gosuna.quickride.DriverApp-TbALx_qfr2LZZ3tQHO5-aw==/lib/arm64/libmapbox-gl.so
01-28 14:28:34.791 25263 25263 F DEBUG   :     #02 pc 00000000000b5250  /data/app/com.gosuna.quickride.DriverApp-TbALx_qfr2LZZ3tQHO5-aw==/lib/arm64/libmapbox-gl.so
01-28 14:28:34.791 25263 25263 F DEBUG   :     #03 pc 00000000000b52a0  /data/app/com.gosuna.quickride.DriverApp-TbALx_qfr2LZZ3tQHO5-aw==/lib/arm64/libmapbox-gl.so
01-28 14:28:34.791 25263 25263 F DEBUG   :     #04 pc 0000000000553bf0  /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #05 pc 000000000054ab88  /system/lib64/libart.so (art_quick_invoke_stub+584)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #06 pc 00000000000dc594  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+204)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #07 pc 000000000029b498  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #08 pc 0000000000295a8c  /system/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+700)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #09 pc 0000000000533d64  /system/lib64/libart.so (MterpInvokeDirect+356)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #10 pc 000000000053ca14  /system/lib64/libart.so (ExecuteMterpImpl+14484)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #11 pc 0000000000275bfc  /system/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue, bool)+444)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #12 pc 000000000052544c  /system/lib64/libart.so (artQuickToInterpreterBridge+1052)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #13 pc 0000000000553d0c  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
01-28 14:28:34.791 25263 25263 F DEBUG   :     #14 pc 00000000001af22c  /dev/ashmem/dalvik-jit-code-cache (deleted)
01-28 14:28:36.861   865   865 E /system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_07
01-28 14:28:36.863  1114 25264 W ActivityManager:   Force finishing activity com.gosuna.quickride.DriverApp/.activities.main.MainActivity
01-28 14:28:36.871  1114  1143 I ActivityManager: Showing crash dialog for package com.gosuna.quickride.DriverApp u0
01-28 14:28:36.871  1114  1157 I BootReceiver: Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
01-28 14:28:36.905  1114  3248 I OpenGLRenderer: Initialized EGL, version 1.4
01-28 14:28:36.905  1114  3248 D OpenGLRenderer: Swap behavior 2
01-28 14:28:36.912  1114  1300 W InputDispatcher: channel '289fbfc com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
01-28 14:28:36.912  1114  1300 E InputDispatcher: channel '289fbfc com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-28 14:28:36.913  1114 14103 I WindowManager: WIN DEATH: Window{289fbfc u0 com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity}
01-28 14:28:36.913  1114 14103 W InputDispatcher: Attempted to unregister already unregistered input channel '289fbfc com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity (server)'
01-28 14:28:36.913   603   621 E SurfaceFlinger: Failed to find layer (SurfaceView - com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity#0) in layer parent (no-parent).
01-28 14:28:36.913   603   621 E SurfaceFlinger: Failed to find layer (Background for - SurfaceView - com.gosuna.quickride.DriverApp/com.gosuna.quickride.DriverApp.activities.main.MainActivity#0) in layer parent (no-parent).
01-28 14:28:36.913  1114  1124 I ActivityManager: Process com.gosuna.quickride.DriverApp (pid 24698) has died: fore TOP
01-28 14:28:36.914  1114  1124 W ActivityManager: Scheduling restart of crashed service com.gosuna.quickride.DriverApp/com.mapbox.services.android.telemetry.service.TelemetryService in 1000ms
01-28 14:28:36.914  1114  1145 W zygote64: kill(-24698, 9) failed: No such process
01-28 14:28:36.915   710   710 I Zygote  : Process 24698 exited due to signal (11)
01-28 14:28:36.925  1114  1160 W ActivityManager: setHasOverlayUi called on unknown pid: 24698
01-28 14:28:36.926  1114  2176 I ActivityManager: Killing 22924:com.google.android.gms.learning/u0a11 (adj 906): empty #17
01-28 14:28:36.937  1114  1145 W zygote64: kill(-24698, 9) failed: No such process
01-28 14:28:36.937  1114  1145 I zygote64: Successfully killed process cgroup uid 10287 pid 24698 in 22ms
01-28 14:28:36.937  1114  1145 W zygote64: kill(-22924, 9) failed: No such process
01-28 14:28:36.942  1114  1145 W zygote64: kill(-22924, 9) failed: No such process
01-28 14:28:36.942  1114  1145 I zygote64: Successfully killed process cgroup uid 10011 pid 22924 in 5ms
01-28 14:28:36.988 14597 14597 W SessionLifecycleManager: Handover failed. Creating new session controller.
@briandilley
Copy link
Author

I noticed that i can get this to happen by quickly going to and leaving the navigation screen over and over again. Sometimes takes longer than others though.

@danesfeder
Copy link
Contributor

Hey @briandilley, we have some known quirks with our Maps SDK used in a Fragment implementation that we are working on. Are you calling NavigationView#onDestroy in Fragment#onDestroyView?

@briandilley
Copy link
Author

@danesfeder here's my fragment:


public class NavigationFragment
    extends BaseFragment {

    private static final int ROUTE_STARTED_MILESTONE     = 1_000;
    private static final int ROUTE_FINISHED_MILESTONE    = 2_000;

    private static final String TAG = "QR/NavigationFragment";

    private ShuttleRideService shuttleRideService = Api.getShuttleRideService();
    private NavigationView navigationView;
    private DriverUpdatesWebSocket socket;
    private String lastGeometry;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_navigation, null);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        socket = new DriverUpdatesWebSocket();
        socket.setAutoReconnect(true);
        socket.open();

        navigationView = view.findViewById(R.id.navigationView);
        navigationView.onCreate(savedInstanceState);
        navigationView.getNavigationAsync(() -> {

            final Location dest = Config.getRide().getDestinationLocation();

            GeoLocation.getCurrentLocation(getMainActivity())
                    .compose(bindToLifecycle())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe((loc) -> navigationView.startNavigation(NavigationViewOptions.builder()
                            .origin(Point.fromLngLat(loc.getLongitude(), loc.getLatitude()))
                            .destination(Point.fromLngLat(
                                    dest.getPoint().getLon(),
                                    dest.getPoint().getLat()))
                            .routeListener(new RouteListener() {

                                @Override
                                public void onRerouteAlong(DirectionsRoute directionsRoute) {
                                    Log.d(TAG, "onRerouteAlong(" + directionsRoute.hashCode() + ")");
                                    updateServer(null, directionsRoute);
                                }

                                @Override public boolean allowRerouteFrom(Point offRoutePoint) {
                                    Log.d(TAG, "allowRerouteFrom(" + offRoutePoint + ")");
                                    return true;
                                }

                                @Override public void onOffRoute(Point offRoutePoint) {
                                    Log.d(TAG, "allowRerouteFrom(" + offRoutePoint + ")");
                                }

                                @Override public void onFailedReroute(String errorMessage) {
                                    Log.d(TAG, "onFailedReroute(" + errorMessage + ")");
                                    Analytics.logEvent("FailedReRoute",
                                            "errorMessage", errorMessage);
                                }
                            })
                            .navigationListener(new NavigationListener() {
                                @Override
                                public void onCancelNavigation() {
                                    Log.d(TAG, "onCancelNavigation()");
                                    onBackPressed();
                                }

                                @Override
                                public void onNavigationFinished() {
                                    Log.d(TAG, "onNavigationFinished()");
                                }

                                @Override
                                public void onNavigationRunning() {
                                    Log.d(TAG, "onNavigationRunning()");
                                    subscribeToMilestones();
                                }
                            })
                            .milestoneEventListener((routeProgress, instruction, milestone) -> {
                                Log.d(TAG, "onMilestoneEvent("
                                        + routeProgress.distanceRemaining()
                                        + ", " + instruction
                                        + ", " + milestone.getIdentifier() + ")");
                                handleMilestone(milestone);
                            })
                            .progressChangeListener((location, routeProgress) -> {
                                Log.d(TAG, "onProgressChange("
                                        + location.getLatitude()+" x "+location.getLongitude()
                                        + ", "+ routeProgress.distanceRemaining() + ")");
                                updateServer(location, routeProgress.directionsRoute());
                            })
                            //.shouldSimulateRoute(true) // - debugging only, causes a crash on exit though
                            .build()));
        });

        if (savedInstanceState != null) {
            navigationView.onRestoreInstanceState(savedInstanceState);
        }
    }

    @Override
    public void onLowMemory() {
        super.onLowMemory();
        if (navigationView != null) {
            navigationView.onLowMemory();
        }
    }

    @Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
        super.onViewStateRestored(savedInstanceState);
        if(savedInstanceState != null) {
            navigationView.onRestoreInstanceState(savedInstanceState);
        }
    }

    @Override
    public void onSaveInstanceState(@NonNull Bundle outState) {
        if (navigationView != null) {
            navigationView.onSaveInstanceState(outState);
        }
        super.onSaveInstanceState(outState);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (navigationView != null) {
            navigationView.onDestroy();
        }
        if (socket != null) {
            socket.close();
        }
    }

    @Override
    public boolean onBackPressed() {

        if (navigationView!= null
                && navigationView.onBackPressed()) {
            return false;
        }

        Observable.just(Config.getRide().needsPickup())
                .compose(bindToLifecycle())
                .observeOn(AndroidSchedulers.mainThread())
                .... removed for brevity ...
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(
                        (accessToken) -> cancelNavigation(),
                        (error) -> Analytics.logNonFatal("Leaving Navigation", error));

        return false;
    }

    private void cancelNavigation() {
        if (getMainActivity() == null) {
            Log.w(TAG, "detatched: not canceling navigation");
            return;
        }

        NavigationViewModel vm =ViewModelProviders
                .of(getMainActivity())
                .get(NavigationViewModel.class);

        if (vm.getNavigation() != null) {
            vm.getNavigation().endNavigation();
        }

        Config.setRide(null);
        getMainActivity().onBackPressed(true);
    }

    private void subscribeToMilestones() {
        if (getMainActivity() == null) {
            Log.w(TAG, "detatched: not subscribing to milestones");
            return;
        }

        NavigationViewModel model = ViewModelProviders
                .of(getMainActivity())
                .get(NavigationViewModel.class);
        model.getNavigation().addMilestone(new RouteMilestone.Builder()
                .setIdentifier(ROUTE_STARTED_MILESTONE)
                .setTrigger(Trigger.all(
                        Trigger.eq(TriggerProperty.FIRST_STEP, TriggerProperty.TRUE))
                )
                .build());
        model.getNavigation().addMilestone(new RouteMilestone.Builder()
                .setIdentifier(ROUTE_FINISHED_MILESTONE)
                .setTrigger(Trigger.all(
                        Trigger.eq(TriggerProperty.LAST_STEP, TriggerProperty.TRUE),
                        Trigger.any(
                                Trigger.lte(TriggerProperty.STEP_DURATION_REMAINING_SECONDS, 10d),
                                Trigger.lte(TriggerProperty.STEP_DISTANCE_REMAINING_METERS, 30d)))
                )
                .build());
    }

    private void handleMilestone(Milestone milestone) {
        if (getMainActivity() == null) {
            Log.w(TAG, "detatched: not handling milestone");
            return;
        }
        ... removed for brevity ...
    }

    private void updateServer(
            @Nullable android.location.Location location,
            @Nullable DirectionsRoute route) {

        if (getMainActivity() == null) {
            Log.w(TAG, "detatched: not updating server");
            return;
        }
        ... removed for brevity ...
    }
}

@danesfeder
Copy link
Contributor

@briandilley Yeah thanks for your code, everything there looks fine to me. This is a native crash happening in our Maps SDK.

@tobrun does this native stack trace give you any hints or do we need to symbolicate it?

@briandilley
Copy link
Author

briandilley commented Feb 2, 2018 via email

@harisqurashi
Copy link

@danesfeder any update on this issue, this is critical for our project.

@danesfeder
Copy link
Contributor

@briandilley @m-harisqurashi I'm thinking this issue stems from the NavigationView looking at 2 different lifecycles when being used in a Fragment.

We tried to remove some boilerplate with the new arch components LifecycleObserver https://github.com/mapbox/mapbox-navigation-android/blob/master/libandroid-navigation-ui/src/main/java/com/mapbox/services/android/navigation/ui/v5/NavigationView.java#L615-L633

But the Activity that adds the Fragment is the LifecycleOwner, so we use those trigger for the map lifecycle methods. In this case, calling NavigationView#onDestroy in the Fragment is not in sync with the actual Activity lifecycle it seems. Causing our MapView not shutdown properly.

Removing the arch components should fix this - you will just need to implement a little more boilerplate code with NavigationView. We will continue to dig.

@jan-otvinovsky
Copy link

Hello, we at NaviRider have the same issue, is there some workaround of this behavior ?
Navigation view is inside fragment view.
We using following versions of libs:

  • com.mapbox.mapboxsdk:mapbox-android-sdk:5.5.0
  • com.mapbox.mapboxsdk:mapbox-android-navigation:0.11.0
  • com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.11.0

please help

@briandilley
Copy link
Author

We (at Quickride) moved off of using a Fragment for this very reason.

@danesfeder
Copy link
Contributor

#806 is moving to address this. Thanks for your patience @briandilley @jan-otvinovsky

@jan-otvinovsky
Copy link

I'm confirming that in version 0.13 works without described problems even in fragment, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants