-
Notifications
You must be signed in to change notification settings - Fork 239
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
FontContext::fetch segfaults in Android in Scene Update #978
Comments
In specific, I did some log messages in Android's bool startUrlRequest(const std::string& _url, UrlCallback _callback) {
LOG("android native startUrlRequest _url: %s", _url.c_str());
jstring jUrl = jniRenderThreadEnv->NewStringUTF(_url.c_str());
LOG("jstring jUrl = jniRenderThreadEnv->NewStringUTF(_url.c_str());");
// This is probably super dangerous. In order to pass a reference to our callback we have to convert it
// to a Java type. We allocate a new callback object and then reinterpret the pointer to it as a Java long.
// In Java, we associate this long with the current network request and pass it back to native code when
// the request completes (either in onUrlSuccess or onUrlFailure), reinterpret the long back into a
// pointer, call the callback function if the request succeeded, and delete the heap-allocated UrlCallback
// to make sure nothing is leaked.
jlong jCallbackPtr = reinterpret_cast<jlong>(new UrlCallback(_callback));
LOG("jlong jCallbackPtr = reinterpret_cast<jlong>(new UrlCallback(_callback));");
jboolean methodResult = jniRenderThreadEnv->CallBooleanMethod(tangramInstance, startUrlRequestMID, jUrl, jCallbackPtr);
LOG("jboolean methodResult = jniRenderThreadEnv->CallBooleanMethod(tangramInstance, startUrlRequestMID, jUrl, jCallbackPtr);");
return methodResult;
} This is the corresponding log:
What's odd is that it looks like that string transformation doesn't happen. But, that might just be the log not up to date with execution? The long warning in the comments is suggesting to me something is going wrong here. |
Looking a bit at this problem, we were noticing that Here's an example: http://stackoverflow.com/questions/2054598/how-to-catch-jni-java-exception jclass c = env->FindClass("class/does/not/Exist");
if (env->ExceptionCheck()) {
return;
}
// otherwise do something with 'c'... |
Just noticed this happening on master: Stacktrace:
|
- Cause was a bad JNI environment on startUrlRequest - Fixed with attaching current url thread to the jni and grabbing jniEnvironment from it. (Apparently we already had a wrapper class doing this, which was not used here) Fixes #978
- Cause was a bad JNI environment on startUrlRequest - Fixed with attaching current url thread to the jni and grabbing jniEnvironment from it. (Apparently we already had a wrapper class doing this, which was not used here) Fixes #978
rebased+squashed mbtiles branch from Nicholas Hallahan Added SQLiteCpp Added mbtiles parameter to data sources and scene.yam #960 Created MBTilesTileTask. #960 Basic MBTiles functionality working! #960 No need to make 2 vectors. Writing SQLite blob directly into rawTileData #960 Database and Statements are class members. Now caching network tiles in MBTiles. #960 Now creating fresh MBTiles caches. Using schema from node-mbtiles. #960 Working on dynamically setting MBTiles from Tangram::Map interface. #960 Remove setMBTiles functions. Going with Scene Updates. Also isOfflineOnly is now hasNoURL. #960 MBTiles Scene Update working on Android when commenting out fonts. #978 #960 Create Map::setMBTiles and exposing it through JNI #960 Added MD5 hash for join key on MBTiles tile and images tables #960 Write to metadata table when setting up MBTiles #960 ClientGeoJsonSource will never have MBTiles #960 fixup disable failing cpplint.py checks Implemented mimeType method in TestDataSource compression: identity when there is no compression linux target_link_libraries includes dl in core Cleaner way of setting target_link_libraries to include dl for Linux.
rebased+squashed mbtiles branch from Nicholas Hallahan Added SQLiteCpp Added mbtiles parameter to data sources and scene.yam #960 Created MBTilesTileTask. #960 Basic MBTiles functionality working! #960 No need to make 2 vectors. Writing SQLite blob directly into rawTileData #960 Database and Statements are class members. Now caching network tiles in MBTiles. #960 Now creating fresh MBTiles caches. Using schema from node-mbtiles. #960 Working on dynamically setting MBTiles from Tangram::Map interface. #960 Remove setMBTiles functions. Going with Scene Updates. Also isOfflineOnly is now hasNoURL. #960 MBTiles Scene Update working on Android when commenting out fonts. #978 #960 Create Map::setMBTiles and exposing it through JNI #960 Added MD5 hash for join key on MBTiles tile and images tables #960 Write to metadata table when setting up MBTiles #960 ClientGeoJsonSource will never have MBTiles #960 fixup disable failing cpplint.py checks Implemented mimeType method in TestDataSource compression: identity when there is no compression linux target_link_libraries includes dl in core Cleaner way of setting target_link_libraries to include dl for Linux.
rebased+squashed mbtiles branch from Nicholas Hallahan Added SQLiteCpp Added mbtiles parameter to data sources and scene.yam #960 Created MBTilesTileTask. #960 Basic MBTiles functionality working! #960 No need to make 2 vectors. Writing SQLite blob directly into rawTileData #960 Database and Statements are class members. Now caching network tiles in MBTiles. #960 Now creating fresh MBTiles caches. Using schema from node-mbtiles. #960 Working on dynamically setting MBTiles from Tangram::Map interface. #960 Remove setMBTiles functions. Going with Scene Updates. Also isOfflineOnly is now hasNoURL. #960 MBTiles Scene Update working on Android when commenting out fonts. #978 #960 Create Map::setMBTiles and exposing it through JNI #960 Added MD5 hash for join key on MBTiles tile and images tables #960 Write to metadata table when setting up MBTiles #960 ClientGeoJsonSource will never have MBTiles #960 fixup disable failing cpplint.py checks Implemented mimeType method in TestDataSource compression: identity when there is no compression linux target_link_libraries includes dl in core Cleaner way of setting target_link_libraries to include dl for Linux.
rebased+squashed mbtiles branch from Nicholas Hallahan Added SQLiteCpp Added mbtiles parameter to data sources and scene.yam #960 Created MBTilesTileTask. #960 Basic MBTiles functionality working! #960 No need to make 2 vectors. Writing SQLite blob directly into rawTileData #960 Database and Statements are class members. Now caching network tiles in MBTiles. #960 Now creating fresh MBTiles caches. Using schema from node-mbtiles. #960 Working on dynamically setting MBTiles from Tangram::Map interface. #960 Remove setMBTiles functions. Going with Scene Updates. Also isOfflineOnly is now hasNoURL. #960 MBTiles Scene Update working on Android when commenting out fonts. #978 #960 Create Map::setMBTiles and exposing it through JNI #960 Added MD5 hash for join key on MBTiles tile and images tables #960 Write to metadata table when setting up MBTiles #960 ClientGeoJsonSource will never have MBTiles #960 fixup disable failing cpplint.py checks Implemented mimeType method in TestDataSource compression: identity when there is no compression linux target_link_libraries includes dl in core Cleaner way of setting target_link_libraries to include dl for Linux.
While working on MBTiles Support (#960), I've found that I can very nicely add an MBTiles file to a data source dynamically using the scene update mechanism. This works great on OS X, but it segfaults on Android.
After doing a bit of debugging, I've pinpointed that this is when we re-fetch a font if it has been specified in the
scene.yaml
. In specific, it happens right when we do thestartUrlRequest
call. It makes sense that this happens only one one platform, since this is platform specific code.If I comment out the font block and the references to it in the
scene.yaml
, my scene update activating MBTiles works.The text was updated successfully, but these errors were encountered: