mapbox / mapbox/mapbox-navigation-android

ViewportDataSourceProcessor following padding does not fit the map

Open
#7,225 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
651
Forks
321
PR merge metrics
No merged PRs in 30d

Description

**Android API:**
**Mapbox Navigation SDK 2.10.2: also tried 2.11.0, 2.12.0, and 2.13.0**

We having issues with Mapbox Navigation Drop-in UI when the app opens and goes to the navigation screen to start navigating the app does get automatically closes and we receive the following error:

`E/Mapbox: [nav-sdk]: [ViewportDataSourceProcessor] Provided following padding does not fit the map size:
mapSize: [width: 1080.0, height: 99.0]
padding: [top: 138.0, left: 138.0, bottom: 41.0, right: 138.0]
Using an empty fallback padding instead: [top: 138.0, left: 138.0, bottom: 41.0, right: 138.0]
E/Mapbox: [nav-sdk]: [ViewportDataSourceProcessor] Provided following padding does not fit the map size:
mapSize: [width: 1080.0, height: 99.0]
padding: [top: 138.0, left: 138.0, bottom: 173.0, right: 138.0]
Using an empty fallback padding instead: [top: 138.0, left: 138.0, bottom: 173.0, right: 138.0]
A/libc: Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7fde2cd5f8 in tid 3039 (nder.production), pid 3039 (nder.production)`

### Steps to trigger behavior

### Expected behavior
We expect the app to start navigating to the given destination

### Actual behavior
The close itself as soon the navigation map gets rendered on the screen.

### Implementations:

```XML

```

```JAVA
package com.responder.production.mapBox;

import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.mapbox.navigation.core.MapboxNavigation;
import com.mapbox.navigation.core.lifecycle.MapboxNavigationApp;
import com.mapbox.navigation.dropin.NavigationView;
import com.mapbox.geojson.Point;
import com.aura.responder.production.R;
import com.mapbox.navigation.dropin.actionbutton.ActionButtonDescription;
import java.util.Arrays;
import java.util.logging.Logger;
import com.mapbox.navigation.ui.base.view.MapboxExtendableButton;
import com.aura.responder.production.mapBox.MapBoxNavigationListener;
import com.aura.responder.production.mapBox.MapBoxRequestRoute;

public class MapBoxWidget extends LinearLayout {

private View view;
private NavigationView navigationView;
private ReactContext objectContext;
private MapBoxNavigationListener mapBoxNavigationListener;
private Logger logger = Logger.getLogger(MapBoxWidget.class.getName());

public MapBoxWidget(ReactContext context) {
super(context);
objectContext = context;
view = inflate(getContext(), R.layout.mapbox_activity_navigation_view, null);
addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

navigationView = view.findViewById(R.id.navigationView);
MapBoxNavigationListener mapBoxNavigationListener = new MapBoxNavigationListener(context);
navigationView.addListener(mapBoxNavigationListener);

// ViewStyleCustomization (Style UI Components)
navigationView.customizeViewStyles(viewStyleCustomization -> {
// viewStyleCustomization.
return null;
});

// ViewOptionsCustomization (Customize options)
navigationView.customizeViewOptions(viewOptionsCustomization -> {
viewOptionsCustomization.setShowRecenterActionButton(true); // ToDo pass through props
viewOptionsCustomization.setShowSpeedLimit(true); // ToDo pass through props
return null;
});
}

public void setMinimumHeight(Integer minimumHeight) {
navigationView.setMinimumHeight(minimumHeight);
}

public void setNavigationProps(Point origin, Point destination, ReadableMap properties) {
navigateUserResponder(origin, destination, properties);
}

private void navigateUserResponder(Point origin, Point destination, ReadableMap properties) {

Boolean shouldStartNavigating = properties.getBoolean("shouldStartNavigating");
Boolean shouldReNavigate = properties.getBoolean("shouldReNavigate");
Boolean shouldExitNavigating = properties.getBoolean("shouldExitNavigating");
Boolean shouldHideNavigationButton = properties.hasKey("shouldHideNavigationButton") ? properties.getBoolean("shouldHideNavigationButton") : Boolean.TRUE;
Boolean shouldSimulatorToDestination = properties.hasKey("shouldSimulatorToDestination") ? properties.getBoolean("shouldSimulatorToDestination") : Boolean.FALSE;
Boolean shouldShowCancelButton = properties.hasKey("shouldShowCancelButton") ? properties.getBoolean("shouldShowCancelButton") : Boolean.FALSE;
Boolean shouldShowCustomButtons = properties.hasKey("shouldShowCustomButtons") ? properties.getBoolean("shouldShowCustomButtons") : Boolean.FALSE;
Boolean shouldMarkAsArrived = properties.hasKey("shouldMarkAsArrived") ? properties.getBoolean("shouldMarkAsArrived") : Boolean.FALSE;
Boolean shouldStopTripSession = properties.hasKey("shouldStopTripSession") ? properties.getBoolean("shouldStopTripSession") : Boolean.FALSE;

navigationView.customizeViewOptions(viewOptionsCustomization -> {
viewOptionsCustomization.setShowEndNavigationButton(shouldShowCancelButton);
return null;
});

// enabling automatic simulator for development use only
navigationView.getApi().routeReplayEnabled(shouldSimulatorToDestination);

if (shouldStartNavigating) {
if (shouldHideNavigationButton && origin.coordinates() != null) {
MapBoxRequestRoute mapBoxRequestRoute = new MapBoxRequestRoute();
mapBoxRequestRoute.requestRoutes(objectContext, navigationView, origin, destination);
} else {
navigationView.getApi().startDestinationPreview(destination);
navigationView.getApi().isReplayEnabled();
navigationView.getApi().startRoutePreview();
navigationView.getApi().startActiveGuidance();
}
}

MapboxNavigation currentMapboxNavigationApp = MapboxNavigationApp.current();
if (shouldStopTripSession && currentMapboxNavigationApp != null) currentMapboxNavigationApp.stopTripSession();
if (shouldExitNavigating || shouldMarkAsArrived) {
navigationView.getApi().startFreeDrive();
if (currentMapboxNavigationApp != null) {
currentMapboxNavigationApp.stopTripSession();
}
if (mapBoxNavigationListener != null) navigationView.removeListener(mapBoxNavigationListener);
}

navigationView.customizeViewBinders(viewBinderCustomization -> {
viewBinderCustomization.defaultSpeedInfoBinder();
if (shouldShowCustomButtons) {
viewBinderCustomization.setCustomActionButtons(Arrays.asList(
new ActionButtonDescription(
onCompleteClicked(R.drawable.ic_baseline_check_circle_outline_24),
ActionButtonDescription.Position.END
),
new ActionButtonDescription(
onMoreClicked(R.drawable.ic_baseline_grid_view_24),
ActionButtonDescription.Position.END
)
));
}
return null;
});
}

public View onCompleteClicked(@DrawableRes int image) {
MapboxExtendableButton mapboxExtendableButton = new MapboxExtendableButton(objectContext);
mapboxExtendableButton.setState(new MapboxExtendableButton.State(image, "", 0));
mapboxExtendableButton.setOnClickListener(view -> {
WritableMap params = Arguments.createMap();
params.putBoolean("completeClicked", Boolean.TRUE);
sendEvent(objectContext, "onCompleteClicked", params);
});
return mapboxExtendableButton;
}

public View onMoreClicked(@DrawableRes int image) {
MapboxExtendableButton mapboxExtendableButton = new MapboxExtendableButton(objectContext);
mapboxExtendableButton.setState(new MapboxExtendableButton.State(image, "", 0));
mapboxExtendableButton.setOnClickListener(view -> {
WritableMap params = Arguments.createMap();
params.putBoolean("moreClicked", Boolean.TRUE);
sendEvent(objectContext, "onMoreClicked", params);
});
return mapboxExtendableButton;
}

private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit(eventName, params);
}
}
```

Any help will be much appreciated, please note that this is a native module which we actually want use in react native app

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the reported MapBoxWidget Java integration and the mapbox_activity_navigation_view XML layout, then trace when NavigationView is created and navigation starts. Compare the logged map size and padding with the SDK's ViewportDataSourceProcessor behavior; done means reproducing the crash or documenting why the integration produces invalid dimensions and covering the result with a focused test.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.