Search code examples
androidskmaps

Adding SKPolyline on SKMapSurfaceView causes SIGABRT


I'm attempting to add a list of SKCoordinates to SKMapSurfaceview map in an SKPolyline. When performing SKSurfaceView.addPolyline( SKPolyline )

I'm getting a Fatal signal 6 SIGABRT from libc.

MapActivity.java

public class MapActivity extends BaseRouteActivity 
{

    ...

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        SKMapSurfaceView mapView = SKMapViewHolder mapHolder = (SKMapViewHolder)
                    findViewById(map_target);
        mapView = mapHolder.getMapSurfaceView();
        mapView.setMapSurfaceListener(this);

        List<SKCoordinate> coordinates = new ArrayList<SKCoordinate>();
        coordinates.add( new SKCoordinate( 52.390846319385254, 4.643051476057394 ) );
        coordinates.add( new SKCoordinate( 52.391088576419605, 4.643212408598288 ) );

        SKPolyline polyline = new SKPolyline();
        polyline.setNodes(coordinates);

        mapView.addPolyline(polyline);   
    }

    ...
}

Logcat error

8009-8009/com.my.app A/libc﹕ Fatal signal 6 (SIGABRT) at 0x00001f49 (code=-6), thread 8009 (y.app)

I've tried wrapping the addPolyline in a UIThread/AsyncTask since I read that Android kills all network traffic in UI blocking functions, but to no avail.

What am I missing?

EDIT #1: After some more digging in LogCat I am getting this error:

JNI WARNING: GetFloatArrayElements received null array
in Lcom/skobbler/ngx/map/MapRenderer;.addobjectpolyline:([D[D[F[FIIII)I (GetFloatArrayElements)

Solution

  • This is an SDK issue that will be fixed with the next release. The crash occurs when the color and outlineColor properties for styling the SKPolyline object are not specified. To avoid the crash you should specify the styling properties for the polyline, like in the code below:

    List<SKCoordinate> coordinates = new ArrayList<SKCoordinate>(); 
    coordinates.add( new SKCoordinate( 52.390846319385254, 4.643051476057394 ) ); 
    coordinates.add( new SKCoordinate( 52.391088576419605, 4.643212408598288 ) ); 
    
    SKPolyline polyline = new SKPolyline(); 
    polyline.setNodes(coordinates); 
    
    // set styling properties (crash will occur if color or outlineColor are not specified) 
    polyline.setLineSize(9); 
    polyline.setOutlineSize(4); 
    polyline.setColor(new float[] {0, 0, 0, 1}); 
    polyline.setOutlineColor(new float[] {0, 0, 0, 1}); 
    polyline.setOutlineDottedPixelsSolid(6); 
    polyline.setOutlineDottedPixelsSkip(0); 
    
    mapView.addPolyline(polyline);