You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
I started of with the a native executable running only the 'simple' tests. With great help from @tmpsantos we got some 20 unit tests to run on the device. However, it seems that these executables have no access to any kind of vm (as they're not started from dalvik/art). Proceeding with the approach in #4671.
Also, it only compiles with arm-v7. @jfirebaugh suggested updating the ndk. Adding that to the list.
Progress - Runs on a vm now, properly linked with gtest in a shared lib, from the command line. But only for a subset of the tests still. A couple of hacks were needed to get things going:
Got rid of the -whole-archive in test/test.gyphi as it gives linking errors when linking into a shared library - need to make that dependent on the target os.
Commented out one line in jni.cpp as it made it crash - no ideas yet
Still commented out tests that need external resources or a headless renderer - next steps
The crash occurs during setup of the JNI bindings. It's trying to look up the mNativePtr field for the class com.mapbox.mapboxsdk.http.HTTPRequest and for some reason failing. Maybe a class loader issue?
Could be @jfirebaugh . But, if I load the class from the vm side, it loads fine: System.out.println(Class.forName("com.mapbox.mapboxsdk.http.HTTPRequest"));
As long as I comment out the line in jni.cpp where it get's hooked up. If I leave it in, it breaks in the same spot, which seems to indicate it's not a classloading issue as the jni onLoad is triggered by loading the class. To be sure, I've added in a static call to loadLibrary in the HTTPRequest java class.
The crash above was indeed caused by a class loading issue. The underlying cause however was that libjavacrypto.so couldn't be loaded. Fixed that by setting the /system/lib dir explicitly in the LD_LIBRARY_PATH. Have to check the portability of this path.
Completed the port of the nodejs webserver to c++ using cpp-httplib. cpp-httplib seems to have a serious issue with concurrency though. This results in the *FileSource.Load tests failing on the 'test-macos` target because clients can't connect. Other tests all run now against the new webserver.
[ RUN ] OnlineFileSource.Load
/Users/ivo/git/mapbox-gl-native/test/storage/online_file_source.cpp:238: Failure
Value of: res.error
Actual: 8-byte object <B0-76 F0-7C 89-7F 00-00>
Expected: nullptr
Which is: 8-byte object <00-00 00-00 00-00 00-00>
....
In file included from ../../test/storage/online_file_source.cpp:1:
In file included from ../../test/src/mbgl/test/util.hpp:44:
/Users/ivo/git/mapbox-gl-native/mason_packages/android-arm-v7-9/gtest/1.7.0/include/gtest/gtest.h:18998:28: error: invalid operands to binary expression ('const
std::__ndk1::chrono::time_point<std::__ndk1::chrono::system_clock, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1, 1> > >' and 'const
std::experimental::__library_fundamentals_v1::optional<std::__ndk1::chrono::time_point<std::__ndk1::chrono::system_clock, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1, 1> > > >')
GTEST_IMPL_CMP_HELPER_(GT, >);
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/Users/ivo/git/mapbox-gl-native/mason_packages/android-arm-v7-9/gtest/1.7.0/include/gtest/gtest.h:18975:12: note: expanded from macro 'GTEST_IMPL_CMP_HELPER_'
if (val1 op val2) {\
~~~~ ^ ~~~~
../../test/storage/online_file_source.cpp:151:9: note: in instantiation of function template specialization
'testing::internal::CmpHelperGT<std::__ndk1::chrono::time_point<std::__ndk1::chrono::system_clock, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1, 1> > >,
std::experimental::__library_fundamentals_v1::optional<std::__ndk1::chrono::time_point<std::__ndk1::chrono::system_clock, std::__ndk1::chrono::duration<long long, std::__ndk1::ratio<1, 1> > > > >'
requested here
EXPECT_GT(util::now(), res.expires);
^
http tests crash.
On arm-v7:
[ RUN ] HTTPFileSource.HTTP200
Segmentation fault
From logcat:
07-07 11:06:51.272 3690 3690 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-07 11:06:51.273 3690 3690 F DEBUG : Build fingerprint: 'google/bullhead/bullhead:6.0.1/MTC19V/2862947:user/release-keys'
07-07 11:06:51.273 3690 3690 F DEBUG : Revision: 'rev_1.0'
07-07 11:06:51.274 3690 3690 F DEBUG : ABI: 'arm'
07-07 11:06:51.274 3690 3690 F DEBUG : pid: 9499, tid: 9573, name: .0.0.1:3000/... >>> dalvikvm32 <<<
07-07 11:06:51.275 3690 3690 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
07-07 11:06:51.279 4930 6911 W NativeCrashListener: Couldn't find ProcessRecord for pid 9499
07-07 11:06:51.278 3690 3690 W debuggerd: type=1400 audit(0.0:696539): avc: denied { search } for name="tmp" dev="dm-2" ino=752194 scontext=u:r:debuggerd:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
07-07 11:06:51.284 3690 3690 F DEBUG : r0 f1444b80 r1 edafa26c r2 00000000 r3 00000005
07-07 11:06:51.285 3690 3690 E DEBUG : AM write failed: Broken pipe
07-07 11:06:51.286 3690 3690 F DEBUG : r4 70b97108 r5 00000000 r6 12c381c0 r7 12cb6660
07-07 11:06:51.286 3690 3690 F DEBUG : r8 00000000 r9 f13cc300 sl 00000000 fp edafa324
07-07 11:06:51.286 3690 3690 F DEBUG : ip f6e5d000 sp edafa250 lr 7367a879 pc 00000000 cpsr 200b0010
07-07 11:06:51.290 3690 3690 F DEBUG :
07-07 11:06:51.290 3690 3690 F DEBUG : backtrace:
07-07 11:06:51.291 3690 3690 F DEBUG : #00 pc 00000000 <unknown>
07-07 11:06:51.291 3690 3690 F DEBUG : #01 pc 7367a877 /data/dalvik-cache/arm/system@[email protected] (offset 0x1ecf000)
07-07 11:06:51.332 3690 3690 W debuggerd: type=1400 audit(0.0:696540): avc: denied { search } for name="tmp" dev="dm-2" ino=752194 scontext=u:r:debuggerd:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
07-07 11:06:51.345 3690 3690 W debuggerd: type=1400 audit(0.0:696541): avc: denied { search } for name="tmp" dev="dm-2" ino=752194 scontext=u:r:debuggerd:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
07-07 11:06:51.345 3690 3690 W debuggerd: type=1400 audit(0.0:696542): avc: denied { search } for name="tmp" dev="dm-2" ino=752194 scontext=u:r:debuggerd:s0 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0
07-07 11:06:51.463 3690 3690 F DEBUG :
07-07 11:06:51.463 3690 3690 F DEBUG : Tombstone written to: /data/tombstones/tombstone_02
On x86 (emulator)
[----------] 10 tests from HTTPFileSource
[ RUN ] HTTPFileSource.Cancel
[ OK ] HTTPFileSource.Cancel (17 ms)
[ RUN ] HTTPFileSource.HTTP200
java.lang.UnsatisfiedLinkError: No implementation found for int android.util.Log.println_native(int, int, java.lang.String, java.lang.String) (tried Java_android_util_Log_println_1native and Java_android_util_Log_println_1native__IILjava_lang_String_2Ljava_lang_String_2)
at android.util.Log.println_native(Native Method)
at android.util.Log.w(Log.java:181)
at com.mapbox.mapboxsdk.http.HTTPRequest.onFailure(HTTPRequest.java:124)
at com.mapbox.mapboxsdk.http.HTTPRequest.onFailure(HTTPRequest.java:120)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:140)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
java.lang.UnsatisfiedLinkError: No implementation found for int android.util.Log.println_native(int, int, java.lang.String, java.lang.String) (tried Java_android_util_Log_println_1native and Java_android_util_Log_println_1native__IILjava_lang_String_2Ljava_lang_String_2)
at android.util.Log.println_native(Native Method)
at android.util.Log.v(Log.java:118)
at com.mapbox.mapboxsdk.http.HTTPRequest.onResponse(HTTPRequest.java:91)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:133)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Which is weird. The Java class for Log is loaded, but the associated native library isn't. Need to figure out which shared library contains the native implementations.
AssetFileSource crashes
[----------] 6 tests from AssetFileSource
[ RUN ] AssetFileSource.Load
Segmentation fault
07-07 11:39:53.198 3132 3132 E EGL_emulation: tid 3132: eglBindAPI(783): error 0x300c (EGL_BAD_PARAMETER)
07-07 11:39:53.216 3132 3132 E EGL_emulation: tid 3132: eglBindAPI(783): error 0x300c (EGL_BAD_PARAMETER)
But this is also printed for the tests that succeed, might not be related. More probable is that I don't clean up correctly as it seems to lock after a couple of render iterations.
On arm-v7 I don't get these messages (still locks up though). Maybe an emulator issue.
Concerning the crash of the Http tests on Android. After removing the Log.* calls from our HTTPContext class, the tests ran rather smoothly. Turns out that not all native methods from the Android framework are loaded at the proper time. Loading the correct library (System.loadLibrary("android_runtime");) didn't help.
The missing methods native methods are in the util Log class. Registration of these methods seem to go through the AndroidRuntime class: Java_com_android_internal_util_WithFramework_registerNatives or Java_LoadClass_registerNatives. The former is used by WithFramework.java, the later by LoadClass.java.
Both are package protected, so not easily re-usable. But similar functionality shouldn't be too hard to create for our test loader if we can link to either of those functions. Otherwise we can probably stub out the Log class as it is the only class from the runtime we need atm.
Activity
ivovandongen commentedon Jun 23, 2016
I started of with the a native executable running only the 'simple' tests. With great help from @tmpsantos we got some 20 unit tests to run on the device. However, it seems that these executables have no access to any kind of vm (as they're not started from dalvik/art). Proceeding with the approach in #4671.
Also, it only compiles with
arm-v7. @jfirebaugh suggested updating the ndk. Adding that to the list.tobrun commentedon Jun 23, 2016
Linking #2150
[android] #5456 - initial setup with a shared test lib and a main cla…
ivovandongen commentedon Jun 27, 2016
Progress - Runs on a vm now, properly linked with gtest in a shared lib, from the command line. But only for a subset of the tests still. A couple of hacks were needed to get things going:
-whole-archivein test/test.gyphi as it gives linking errors when linking into a shared library - need to make that dependent on the target os.ivovandongen commentedon Jun 27, 2016
Concerning the crash in jni.cpp:
bleege commentedon Jun 27, 2016
/sub
jfirebaugh commentedon Jun 27, 2016
The crash occurs during setup of the JNI bindings. It's trying to look up the
mNativePtrfield for the classcom.mapbox.mapboxsdk.http.HTTPRequestand for some reason failing. Maybe a class loader issue?ivovandongen commentedon Jun 28, 2016
Could be @jfirebaugh . But, if I load the class from the vm side, it loads fine:
System.out.println(Class.forName("com.mapbox.mapboxsdk.http.HTTPRequest"));As long as I comment out the line in jni.cpp where it get's hooked up. If I leave it in, it breaks in the same spot, which seems to indicate it's not a classloading issue as the jni onLoad is triggered by loading the class. To be sure, I've added in a static call to
loadLibraryin the HTTPRequest java class.ivovandongen commentedon Jun 28, 2016
The crash above was indeed caused by a class loading issue. The underlying cause however was that
libjavacrypto.socouldn't be loaded. Fixed that by setting the/system/libdir explicitly in theLD_LIBRARY_PATH. Have to check the portability of this path.90 remaining items
[android] #5456 - Updated the headless renderer
[android] #5456 - Headless renderer - functional on simulator with so…
[android] #5456 - headless view egl - cleanup resources and cleanup code
[android] #5456 - Initial cpp http server
[android] #5456 - cleanup makefile
[android] #5456 - extracted server in separate source files
[android] #5456 - implemented a couple more cases
[android] #5456 - ported the nodejs test server to cpp
ivovandongen commentedon Jul 7, 2016
Completed the port of the nodejs webserver to c++ using cpp-httplib. cpp-httplib seems to have a serious issue with concurrency though. This results in the
*FileSource.Loadtests failing on the 'test-macos` target because clients can't connect. Other tests all run now against the new webserver.ivovandongen commentedon Jul 7, 2016
Remaining issues on android
On the android side of the tests, there are a couple more issues:
I've included the details for these below.
test/storage/online_file_source.cpp won't compile:
http tests crash.
On arm-v7:
From logcat:
On x86 (emulator)
Which is weird. The Java class for Log is loaded, but the associated native library isn't. Need to figure out which shared library contains the native implementations.
AssetFileSource crashes
From logcat+ndk-stack
API.RepeatedRender lockup
On the emulator:
But this is also printed for the tests that succeed, might not be related. More probable is that I don't clean up correctly as it seems to lock after a couple of render iterations.
On arm-v7 I don't get these messages (still locks up though). Maybe an emulator issue.
ivovandongen commentedon Jul 11, 2016
Concerning the crash of the Http tests on Android. After removing the Log.* calls from our HTTPContext class, the tests ran rather smoothly. Turns out that not all native methods from the Android framework are loaded at the proper time. Loading the correct library (
System.loadLibrary("android_runtime");) didn't help.The missing methods native methods are in the util Log class. Registration of these methods seem to go through the AndroidRuntime class:
Java_com_android_internal_util_WithFramework_registerNativesorJava_LoadClass_registerNatives. The former is used by WithFramework.java, the later by LoadClass.java.Both are package protected, so not easily re-usable. But similar functionality shouldn't be too hard to create for our test loader if we can link to either of those functions. Otherwise we can probably stub out the Log class as it is the only class from the runtime we need atm.
tobrun commentedon Dec 21, 2016
@ivovandongen basic integration for x86 has landed, good to close for now?
stale commentedon Nov 24, 2018
This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.