Offline map logcat error
An error occurs when a user tries to download an offline region. Heres the code used to set up the metadata:
// Set the metadata
byte[] metadata;
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put(JSON_FIELD_REGION_NAME, "User downloaded area");
String json = jsonObject.toString();
metadata = json.getBytes(JSON_CHARSET);
} catch (Exception e) {
Log.e(logTag, "Failed to encode metadata: " + e.getMessage());
metadata = null;
}
and the logcat:
V/com.mapbox.mapboxsdk.http.HTTPRequest: [HTTP] Request was successful (code = 200).
E/dalvikvm: JNI ERROR (app bug): local reference table overflow (max=512)
W/dalvikvm: JNI local reference table (0x6b8a5d10) dump:
W/dalvikvm: Last 10 entries (of 512):
W/dalvikvm: 511: 0x43989740 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 510: 0x43989770 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 509: 0x439897a0 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 508: 0x439897d0 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 507: 0x43989800 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 506: 0x43989830 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 505: 0x43989860 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 504: 0x43989890 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 503: 0x439abff0 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: 502: 0x439ac020 com.mapbox.mapboxsdk.offline.OfflineRegionStatus
W/dalvikvm: Summary:
W/dalvikvm: 1 of byte[]
W/dalvikvm: 1 of com.mapbox.mapboxsdk.offline.OfflineRegion
W/dalvikvm: 510 of com.mapbox.mapboxsdk.offline.OfflineRegionStatus (510 unique instances)
E/dalvikvm: Failed adding to JNI local ref table (has 512 entries)
I/dalvikvm: "DefaultFileSource" prio=5 tid=38 RUNNABLE
I/dalvikvm: | group="main" sCount=0 dsCount=0 obj=0x43a38cb0 self=0x6aea4c80
I/dalvikvm: | sysTid=21826 nice=0 sched=0/0 cgrp=apps handle=1793742848
I/dalvikvm: | state=R schedstat=( 7981330396 5527505460 19993 ) utm=423 stm=375 core=1
I/dalvikvm: at android.os.SystemClock.uptimeMillis(Native Method)
I/dalvikvm: at android.os.Handler.sendMessageDelayed(Handler.java:566)
I/dalvikvm: at android.os.Handler.post(Handler.java:326)
I/dalvikvm: at com.mapbox.mapboxsdk.offline.OfflineRegion$1.onStatusChanged(OfflineRegion.java:183)
I/dalvikvm: at dalvik.system.NativeStart.run(Native Method)
E/dalvikvm: VM aborting
A/libc: Fatal signal 6 (SIGABRT) at 0x0000531f (code=-6), thread 21826 (.android.tablet)
Any ideas here whats going on? @jfirebaugh @zugaldia
@cammace could you post the rest of the activity, or at least the offline-related code? Also, do we have details on device brand and model?
The users activity can be found here. I'll follow up with device brand and model when I get more info.
User was using the 4.1.0-SNAPSHOT version of the SDK, switching over to 4.0.0 fixed the issue.
@cammace interesting, that could indicate that we've introduced a regression in the offline code. Let's keep the issue open, I'd like to make sure that 4.1-final doesn't have this.
After further testing version 4.1.0-snapshot causes the SIGABRT when downloading the region. Using 4.0.0 stable allows the map to be downloaded properly but the map does not load when the the downloaded region is being viewed with the downloaded zoom levels. The area that is being viewed appears as a black region on the satellite style and a beige color on the mapbox-streets style. I attempted downloading the region on the stable and trying to see if I would be able to view them on 4.1.0-snapshot and was still unable to see the downloaded region. Code is here. The used XML page is here If you want to attempt to test it your self:
- Open app on a network connection
- Zoom to a location (you will have to do this manually)
- In the top right press the button titled "Advanced options" (You can also switch between satellite and streets here)
- Press save map and wait for the download to finish, there is a progress indicator as well as a alert dialog that shows when the map finishes downloading.
- Close app and turn of network connection.
- Open app again and zoom to location.
@shantanu-vyas It looks like your code downloads the zoom range z19 - z21. This will likely result in 0 offline tiles. Most tilesets only go to zoom 16.
I attempted using a lower tile range capping at 16 then restarting the app, then zooming to the exact downloaded area with zoom level 16 and was able to see the downloaded region for a split second then it disappeared. I'm only able to recreate seeing the map for a split second by restarting the app then panning and zooming to the downloaded region.
@shantanu-vyas I downloaded your code and deployed to a device. I could reproduce your SIGABRT but the logcat I got with the current SNAPSHOT was a bit different:
System.out I bounds: N:38.98988140452869; E:-76.92578385390738; S:38.86172974481016; W:-77.14584754895657
I zoom min0.0
I zoom max21.0
I zoom current 10.53489875793457
RenderScript V 0x8e326000 Launching thread(s), CPUs 4
art W Throwing OutOfMemoryError "PushLocalFrame"
libc F Fatal signal 6 (SIGABRT), code -6 in tid 13888 ()
DEBUG F #00 pc 00041f50 /system/lib/libc.so (tgkill+12)
F #01 pc 0003fb5d /system/lib/libc.so (pthread_kill+32)
F #02 pc 0001c30f /system/lib/libc.so (raise+10)
F #03 pc 000194c1 /system/lib/libc.so (__libc_android_abort+34)
F #04 pc 000174ac /system/lib/libc.so (abort+4)
F #05 pc 00276f98 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so
F #06 pc 0027710c /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so
F #07 pc 0026771c /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so
F #08 pc 00266958 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (__cxa_throw+240)
F #09 pc 000e4b64 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::HTTPRequest::HTTPRequest(_JNIEnv&, mbgl::Res
ource const&, std::__1::function<void (mbgl::Response)>)+1320)
F #10 pc 000e65d0 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::HTTPFileSource::request(mbgl::Resource const
&, std::__1::function<void (mbgl::Response)>)+152)
F #11 pc 000fc148 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::OnlineFileSource::Impl::activateRequest(mbgl
::OnlineFileRequest*)+112)
F #12 pc 0021aba0 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::util::Timer::Impl::runTask()+56)
F #13 pc 00218e20 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::util::RunLoop::Impl::processRunnables()+256)
F #14 pc 00219500 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (mbgl::util::RunLoop::run()+116)
F #15 pc 000f9e24 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (void mbgl::util::Thread<mbgl::DefaultFileSource::I
mpl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned lon
g long&>, 0u, 1u>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsi
gned long long&>&&, std::__1::integer_sequence<unsigned int, 0u, 1u>)+152)
F #16 pc 000f9d48 /data/app/com.platypus.android.tablet-1/lib/arm/libmapbox-gl.so (std::__1::__thread_proxy<std::__1::tuple<mbgl::uti
l::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>
> const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1
::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*)+116)
F #17 pc 0003f45f /system/lib/libc.so (__pthread_start(void*)+30)
F #18 pc 00019b43 /system/lib/libc.so (__start_thread+6)
Process com.platypus.android.tablet (PID: 13371) ended
@tmpsantos I see that the stacktrace includes RunLoop, I wonder if this has anything to do with the changes introduced in https://github.com/mapbox/mapbox-gl-native/issues/4682. Anything I could do to help further troubleshoot this? /cc: @jfirebaugh
Not sure about your stack trace @zugaldia but for the original issue with the "local reference table overflow", I'd guess that there needs to be a PushLocalFrame here.
jni.hpp has a RAII class for this. Example.
@jfirebaugh That's it. I could reproduce the crash in the Test App and I followed your suggestion in https://github.com/mapbox/mapbox-gl-native/pull/4918.