I have java application, where I use C++ code. All c++ code is compiled to .so file.
I have to write unit tests for native part of the project.
I wrote such unit test:
#include <gtest/gtest.h>
#include <gtest-all.cc>
#include <myTestedFile.h>
#include <jni.h>
#include <iostream>
int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
RUN_ALL_TESTS();
return 0;
}
TEST(MyTest, Test1)
{
jclass jc;
int k = jni_return_five((JNIEnv*)0, jc);
ASSERT_EQ(k,5);
}
there is file myTestedFile.cpp
#include "myTestedFile.h"
JNIEXPORT jint JNICALL jni_return_five(JNIEnv *env, jclass cls)
{
jclass commonClass = env->FindClass(
"com/android/appportal/common/Myclass");
return 5;
}
I start this test with such way
adb push libs/armeabi-v7a/myTest /data/local/tmp
adb push libs/armeabi-v7a/myLibrary.so /data/local/tmp
adb shel "LD_LIBRARY_PATH=/data/local/tmp data/local/tmp/myTest"
After this I have output
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from MyTest
[ RUN ] MyTest.Test1
Segmentation fault
Test is passed succesfully, if I dont get references to java classes in the jni code. Can anyone help me with this error?
There is logcat of the crash
F/libc (10105): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 10105 (myLibrary)
I/DEBUG ( 113): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 113): Build fingerprint: 'samsung/espresso10rfxx/espresso10rf:4.0.3/IML74K/P5100XWALE2:user/release-keys'
I/DEBUG ( 113): Revision: '10'
I/DEBUG ( 113): pid: 10105, tid: 10105, name: myLibrary >>> /data/local/tmp/myTest <<<
I/DEBUG ( 113): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
W/NativeCrashListener( 399): Couldn't find ProcessRecord for pid 10105
I/DEBUG ( 113): be8268c8 004e1de8 [heap]
I/DEBUG ( 113): be8268cc be826a6c [stack]
I/DEBUG ( 113): be8268d0 00000001
I/DEBUG ( 113): be8268d4 4021fdb4 /data/local/tmp/libgnustl_shared.so (operator new[](unsigned int)+8)
I/DEBUG ( 113): be8268d8 004e2610 [heap]
I/DEBUG ( 113): be8268dc 0000bc70 /data/local/tmp/myTest
I/DEBUG ( 113): be8268e0 402a22f0 /system/lib/libc.so
I/DEBUG ( 113): be8268e4 004e1e44 [heap]
I/DEBUG ( 113): be8268e8 00039df8 /data/local/tmp/myTest
I/DEBUG ( 113): be8268ec be826918 [stack]
I/DEBUG ( 113): be8268f0 00000000
I/DEBUG ( 113): be8268f4 be82690c [stack]
I/DEBUG ( 113): be8268f8 e3a070ad
I/DEBUG ( 113): be8268fc ef9000ad
I/DEBUG ( 113): #00 be826900 000384c4 /data/local/tmp/myTest
I/DEBUG ( 113): be826904 00000000
I/DEBUG ( 113): be826908 be826924 [stack]
I/DEBUG ( 113): be82690c 0002d9b4 /data/local/tmp/myTest
I/DEBUG ( 113): #01 be826910 004e1ee0 [heap]
I/DEBUG ( 113): be826914 00000000
I/DEBUG ( 113): be826918 00000000
I/DEBUG ( 113): be82691c 00000000
I/DEBUG ( 113): be826920 be82695c [stack]
I/DEBUG ( 113): be826924 0001df80 /data/local/tmp/myTest
I/DEBUG ( 113): #02 be826928 be826944 [stack]
I/DEBUG ( 113): be82692c 0001f040 /data/local/tmp/myTest
I/DEBUG ( 113): be826930 000105cc /data/local/tmp/myTest
I/DEBUG ( 113): be826934 004e2548 [heap]
I/DEBUG ( 113): be826938 004e1ee0 [heap]
I/DEBUG ( 113): be82693c 00039df8 /data/local/tmp/myTest
I/DEBUG ( 113): be826940 be826954 [stack]
I/DEBUG ( 113): be826944 00010620 /data/local/tmp/myTest
I/DEBUG ( 113): be826948 be826954 [stack]
I/DEBUG ( 113): be82694c 004e1ee0 [heap]
I/DEBUG ( 113): be826950 be82695c [stack]
I/DEBUG ( 113): be826954 004e2568 [heap]
I/DEBUG ( 113): be826958 be826974 [stack]
I/DEBUG ( 113): be82695c 00010e30 /data/local/tmp/myTest
I/DEBUG ( 113): be826960 be82696c [stack]
I/DEBUG ( 113): be826964 004e2548 [heap]
I solved this problem with creating of wrapper for JNIEnv class.
Related
I am currently developing an application where after the camera detected a body, an image (shirt) will be overlaid. However, after detecting the body, the camera crashes and my logcat says Fatal signal 6 (SIGABRT), code -6 in tid 23908 (Thread-39833).
Below are the codes I've made so far.
nerds_thesis_clartips_OpencvClass.h //header file
#include <jni.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
#include <stdio.h>
using namespace cv;
using namespace std;
#ifndef _Included_nerds_thesis_clartips_OpencvClass
#define _Included_nerds_thesis_clartips_OpencvClass
#ifdef __cplusplus
extern "C" {
#endif
void detectHuman(Mat& frame);
Mat putShirt(Mat frame, Point center, Size humanSize);
JNIEXPORT void JNICALL Java_nerds_thesis_clartips_OpencvClass_humanDetection
(JNIEnv *, jclass, jlong);
#ifdef __cplusplus
}
#endif
#endif
nerds_thesis_clartips_OpencvClass.cpp //C++ file
#include "nerds_thesis_clartips_OpencvClass.h"
JNIEXPORT void JNICALL Java_nerds_thesis_clartips_OpencvClass_humanDetection
(JNIEnv *, jclass, jlong addrRgba){
Mat& frame = *(Mat*)addrRgba;
detectHuman(frame);
}
void detectHuman(Mat& frame){
// assign xml file to a variable
String human_cascade_name = "/storage/emulated/0/data/haarcascade_upperbody.xml";
CascadeClassifier human_cascade;
// load xml file
if(!human_cascade.load( human_cascade_name ) ) { printf("--(!)Error loading\n"); return; };
std::vector<Rect> humans;
Mat frame_gray;
//convert input to grayscale
cvtColor( frame, frame_gray, CV_BGR2GRAY );
//increase image contrast
equalizeHist( frame_gray, frame_gray);
//Detect Human
human_cascade.detectMultiScale( frame_gray, humans, 1.1, 2, 0 | CV_HAAR_SCALE_IMAGE, Size(100, 100) );
// Draw the mask over all rectangles
for (size_t i = 0; i < humans.size(); i++){
Rect r = humans[i];
Mat humanROI = frame_gray( humans[i] ); //image of the upper body
int h_temp = humans[i].height; // storing original height
int x = humans[i].x;
int y = humans[i].y - h_temp*(-0.6); // y is increased by 0.6*h
int w = humans[i].width;
int h = h_temp; // height detected
rectangle(frame, Point(x,y), Point(x + w,y +h),Scalar(255,0,255));
Point center( humans[i].x + humans[i].width*0.5, humans[i].y + humans[i].height*0.5 );
frame = putShirt(frame,center,Size( humans[i].width, humans[i].height));
}
}
Mat putShirt(Mat frame, Point center, Size humanSize){
Mat mask = imread("C:/Users/Requinala/AndroidStudioProjects/CLARTIPS/app/src/main/res/drawable/bluevelvet.png");
Mat mask1,src1;
resize(mask,mask1,humanSize);
// ROI selection
Rect roi(center.x - humanSize.width/2, center.y - humanSize.width/2, humanSize.width, humanSize.width);
frame(roi).copyTo(src1);
// to make the white region transparent
Mat mask2,m,m1;
cvtColor(mask1,mask2,CV_BGR2GRAY);
threshold(mask2,mask2,230,255,CV_THRESH_BINARY_INV);
vector<Mat> maskChannels(3),result_mask(3);
split(mask1, maskChannels);
bitwise_and(maskChannels[0],mask2,result_mask[0]);
bitwise_and(maskChannels[1],mask2,result_mask[1]);
bitwise_and(maskChannels[2],mask2,result_mask[2]);
merge(result_mask,m ); // imshow("m",m);
mask2 = 255 - mask2;
vector<Mat> srcChannels(3);
split(src1, srcChannels);
bitwise_and(srcChannels[0],mask2,result_mask[0]);
bitwise_and(srcChannels[1],mask2,result_mask[1]);
bitwise_and(srcChannels[2],mask2,result_mask[2]);
merge(result_mask,m1 ); // imshow("m1",m1);
addWeighted(m,1,m1,1,0,m1); // imshow("m2",m1);
m1.copyTo(frame(roi));
return frame;
}
OpencvCamera.java //Java class for camera
public class OpencvCamera extends AppCompatActivity implements CameraBridgeViewBase.CvCameraViewListener2{
Mat mRgba;
#Override
public void onCameraViewStarted(int width, int height) {
mRgba = new Mat(height, width, CvType.CV_8UC4);
}
#Override
public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
mRgba = inputFrame.rgba();
OpencvClass.humanDetection(mRgba.getNativeObjAddr());
return mRgba;
}
}
OpencvClass.java //java class for the jni
public class OpencvClass {
public native static void humanDetection(long addrRgba);
}
logcats
02-24 16:45:36.269 13615-23908/? A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 23908 (Thread-39833)
02-24 16:45:36.372 280-280/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-24 16:45:36.372 280-280/? I/DEBUG: Build fingerprint: 'CMCC/M631Y/M631Y:5.1.1/LMY47V/M631Y_02.24.00RPD_HK.00:user/release-keys'
02-24 16:45:36.372 280-280/? I/DEBUG: Revision: '0'
02-24 16:45:36.372 280-280/? I/DEBUG: ABI: 'arm'
02-24 16:45:36.373 280-280/? I/DEBUG: pid: 13615, tid: 23908, name: Thread-39833 >>> nerds.thesis.clartips <<<
02-24 16:45:36.373 280-280/? I/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
02-24 16:45:36.396 280-280/? I/DEBUG: r0 00000000 r1 00005d64 r2 00000006 r3 00000000
02-24 16:45:36.396 280-280/? I/DEBUG: r4 a4674dd8 r5 00000006 r6 00000000 r7 0000010c
02-24 16:45:36.396 280-280/? I/DEBUG: r8 00000047 r9 00000001 sl a4674400 fp 0000203e
02-24 16:45:36.397 280-280/? I/DEBUG: ip 00005d64 sp a46732a0 lr b6dbfc2d pc b6de5f3c cpsr 600f0010
02-24 16:45:36.397 280-280/? I/DEBUG: backtrace:
02-24 16:45:36.397 280-280/? I/DEBUG: #00 pc 00039f3c /system/lib/libc.so (tgkill+12)
02-24 16:45:36.397 280-280/? I/DEBUG: #01 pc 00013c29 /system/lib/libc.so (pthread_kill+52)
02-24 16:45:36.397 280-280/? I/DEBUG: #02 pc 00014847 /system/lib/libc.so (raise+10)
02-24 16:45:36.397 280-280/? I/DEBUG: #03 pc 00010fd5 /system/lib/libc.so (__libc_android_abort+36)
02-24 16:45:36.397 280-280/? I/DEBUG: #04 pc 0000f534 /system/lib/libc.so (abort+4)
02-24 16:45:36.397 280-280/? I/DEBUG: #05 pc 008a2e50 /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZN9__gnu_cxx27__verbose_terminate_handlerEv+344)
02-24 16:45:36.398 280-280/? I/DEBUG: #06 pc 0087914c /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZN10__cxxabiv111__terminateEPFvvE+4)
02-24 16:45:36.398 280-280/? I/DEBUG: #07 pc 0087918c /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZSt9terminatev+16)
02-24 16:45:36.398 280-280/? I/DEBUG: #08 pc 00878b68 /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (__cxa_throw+168)
02-24 16:45:36.398 280-280/? I/DEBUG: #09 pc 001c8305 /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZN2cv5errorERKNS_9ExceptionE+244)
02-24 16:45:36.398 280-280/? I/DEBUG: #10 pc 001c8445 /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZN2cv5errorEiRKNS_6StringEPKcS4_i+96)
02-24 16:45:36.398 280-280/? I/DEBUG: #11 pc 0037660f /data/app/nerds.thesis.clartips-2/lib/arm/libopencv_java3.so (_ZN2cv6resizeERKNS_11_InputArrayERKNS_12_OutputArrayENS_5Size_IiEEddi+406)
02-24 16:45:36.399 280-280/? I/DEBUG: #12 pc 0000fbf5 /data/app/nerds.thesis.clartips-2/lib/arm/libMyLibs.so (putShirt+172)
02-24 16:45:36.399 280-280/? I/DEBUG: #13 pc 0000f7ab /data/app/nerds.thesis.clartips-2/lib/arm/libMyLibs.so (detectHuman+842)
02-24 16:45:36.399 280-280/? I/DEBUG: #14 pc 0015fc6d /data/dalvik-cache/arm/data#app#nerds.thesis.clartips-2#base.apk#classes.dex
I'm a beginner and I've searched about SIGABRT and it says it has something to do about memory issues. I can't find where I've gone wrong in my codes.
This is very crucial. All helps/ideas will be appreciated because this will serve as my final output in college.
imread("C:/Users/Requinala/AndroidStudioProjects/CLARTIPS/app/src/main/res/drawable/bluevelvet.png")
tires to read the png from your PC disk. No wonder that it fails. You should
always check that result of file read, etc. is OK
read the image from your phone storage, or from assets of your app
You can use Java to extract images from the resources (or assets) to local storage, or you can use the Android assets native API to read such images directly from the APK.
Assets seem to suit your cause better, because the drawable resources are meant to be adapted to the screen resolution.
Using native assets API with imread() is possible, but tricky.
An error occurs at times (more often than not, actually).
A/libc: Fatal signal 11 (SIGSEGV) at 0x830ab2cc (code=1), thread 24294 (Thread-1174)
The code is as follows:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.displaygraph);
Intent intent = getIntent();
GraphView graph = (GraphView) findViewById(R.id.graph);
series = new LineGraphSeries<DataPoint>();
graph.addSeries(series);
Viewport viewport = graph.getViewport();
viewport.setYAxisBoundsManual(true);
viewport.setXAxisBoundsManual(true);
viewport.setMinY(0);
double max=data[0];
for (int i = 0; i < data.length; i++) {
if (data[i] > max) {
max = data[i];
Log.w(TAG,"max"+max);
}
}
viewport.setMaxY(max);
viewport.setMinX(0);
viewport.setMaxX(450);
graph.getViewport().setScalable(true);
graph.getViewport().setScalableY(true);
seriesecg = new LineGraphSeries<DataPoint>();
GraphView graphecg = (GraphView) findViewById(R.id.graphecg);
graphecg.addSeries(seriesecg);
Viewport viewportecg = graphecg.getViewport();
viewportecg.setYAxisBoundsManual(true);
viewportecg.setXAxisBoundsManual(true);
viewportecg.setMinY(0);
viewportecg.setMaxY(3000);
viewportecg.setMinX(0);
viewportecg.setMaxX(450);
graphecg.getViewport().setScalable(true);
graphecg.getViewport().setScalableY(true);
}
#Override
protected void onResume() {
super.onResume();
new Thread(new Runnable() {
#Override
public void run() {
// we add 450 new entries
for (int i = 0; i <= 449; i++) {
final int finalI = i;
final int finalII = i;
Log.w(TAG, "finalI"+finalI);
runOnUiThread(new Runnable() {
#Override
public void run() {
addEntry(finalI,ppg);
}
});
// sleep to slow down the add of entries
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// manage error ...
}
}
}
}).start();
}
// add random data to graph
private void addEntry(int i,double[] data) {
if(i<=449) {
Log.w(TAG, "ppg" + data[i]+"/"+i);
series.appendData(new DataPoint(i, data[i]), false, 450);
}
}
The logcat is as follows:
01-22 19:27:01.650 1041-1370/? I/KeyguardUpdateMonitor: visibility is same
01-22 19:27:01.650 818-818/? D/CrashAnrDetector: Build: samsung/lt03ltezs/lt03lte:4.4.2/KOT49H/P605ZSUCOD1:user/release-keys
Hardware: MSM8974
Revision: 11
Bootloader: P605ZSUCOD1
Radio: unknown
Kernel: Linux version 3.4.0-4665213 (dpi#SWDD5621) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Mon Apr 13 11:19:19 KST 2015
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/lt03ltezs/lt03lte:4.4.2/KOT49H/P605ZSUCOD1:user/release-keys'
Revision: '11'
pid: 12476, tid: 12476, name: elerometergraph >>> com.android.accelerometergraph <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 82f5583c
r0 402aaedb r1 82f55838 r2 402aaed8 r3 42caa968
r4 bedfd1b8 r5 42277008 r6 bedfd20c r7 402aaaa8
r8 00000000 r9 42caad98 sl 416b049c fp 80000000
ip 00000003 sp bedfd010 lr 4172ff51 pc 4172ff3e cpsr 900f0030
d0 0080000000001000 d1 0200000000004000
d2 0000000000000008 d3 0000888800000000
d4 0000004080000000 d5 0000200000000000
d6 1000000000200000 d7 0000800000000010
d8 44618b1844624bf2 d9 3e99999a4040da00
d10 43380000c3892666 d11 c389266644618b18
d12 4252ccd044624bf2 d13 c07124cccccccccd
d14 4034000000000000 d15 43a38000c3892666
d16 0100000000000000 d17 0004400000020000
d18 0004400000000000 d19 2000010000440000
d20 000a402000088100 d21 0000000000044000
d22 0022000000008800 d23 1100000000000000
d24 3fd1b10853a79915 d25 3fd554fa9ca0567a
d26 3fdb6db71408e660 d27 3fe33333332d4313
d28 3ff0000000000000 d29 0000000000000001
d30 4059000000000000 d31 4024000000000000
scr 20000013
backtrace:
#00 pc 00075f3e /system/lib/libdvm.so (mspace_bulk_free+89)
#01 pc 00076e63 /system/lib/libdvm.so (dvmHeapSourceFreeList(unsigned int, void**)+70)
#02 pc 0003a7b4 /system/lib/libdvm.so
#03 pc 0002c4ec /system/lib/libdvm.so (dvmHeapBitmapSweepWalk(HeapBitmap const*, HeapBitmap const*, unsigned int, unsigned int, void (*)(unsigned int, void**, void*), void*)+176)
#04 pc 0003b53c /system/lib/libdvm.so (dvmHeapSweepUnmarkedObjects(bool, bool, unsigned int*, unsigned int*)+284)
#05 pc 0002c94c /system/lib/libdvm.so (dvmCollectGarbageInternal(GcSpec const*)+452)
#06 pc 0002d45c /system/lib/libdvm.so (dvmMalloc(unsigned int, int)+356)
#07 pc 0006cb03 /system/lib/libdvm.so
#08 pc 0002c36f /dev/ashmem/dalvik-jit-code-cache (deleted)
stack:
bedfcfd0 bedfd1ec [stack]
bedfcfd4 40129d5d /system/lib/libc.so (realloc+12)
bedfcfd8 00000008
bedfcfdc bedfd2a8 [stack]
bedfcfe0 78e476f8
bedfcfe4 00000000
bedfcfe8 00000003
bedfcfec bedfd100 [stack]
bedfcff0 42ca9b88 /dev/ashmem/dalvik-heap (deleted)
bedfcff4 bedfd174 [stack]
bedfcff8 42277008 /dev/ashmem/dalvik-heap (deleted)
bedfcffc bedfd20c [stack]
bedfd000 42caa968 /dev/ashmem/dalvik-heap (deleted)
bedfd004 00000000
bedfd008 42caa950 /dev/ashmem/dalvik-heap (deleted)
bedfd00c 4172ff51 /system/lib/libdvm.so (mspace_bulk_free+108)
#00 bedfd010 00029864
bedfd014 416b0438
bedfd018 00000065
bedfd01c 00000065
bedfd020 bedfd078 [stack]
bedfd024 416b0438
bedfd028 42277008 /dev/ashmem/dalvik-heap (deleted)
bedfd02c 41730e67 /system/lib/libdvm.so (dvmHeapSourceFreeList(unsigned int, void**)+74)
#01 bedfd030 00000065
bedfd034 402abf98 /system/lib/libandroidfw.so
bedfd038 bedfd2cc [stack]
bedfd03c bedfd2cc [stack]
bedfd040 00000065
bedfd044 61fff040 /dev/ashmem/dalvik-bitmap-2 (deleted)
bedfd048 617ff040 /dev/ashmem/dalvik-bitmap-1 (deleted)
bedfd04c 0001acbf
bedfd050 bedfd078 [stack]
bedfd054 416f47b8 /system/lib/libdvm.so
#02 bedfd058 00000000
bedfd05c 00000000
bedfd060 00000030
bedfd064 00015010
bedfd068 01501
01-22 19:27:01.650 818-818/? D/CrashAnrDetector: processName:com.android.accelerometergraph
01-22 19:27:01.650 818-818/? D/CrashAnrDetector: broadcastEvent : com.android.accelerometergraph SYSTEM_TOMBSTONE
01-22 19:27:01.660 1041-1055/? D/KeyguardUpdateMonitor: sendKeyguardVisibilityChanged(true)
01-22 19:27:01.660 1041-1055/? I/KeyguardUpdateMonitor: visibility is same
Sometimes the code works but sometimes it doesn't... but when it occurs, it does so before the value of i reaches 449. I thought it had something to do with my jni code. but after commenting and deleting everything that would call a c code, the error still occurred.
Thank you for your help...
I have an activity that displays a screenshot of a map fragment, along with some other things. Everything shows up perfectly until a second or two later when the app crashes. This is only happening on Android phones using 4.4.2 kitkat, but not on tablets. After the first attempt to load this view, it will sometimes crash before even displaying anything when setContentView is called. Since it crashes at a different time each time I test, I assume something is happening on a background thread, and since it's a Fatal signal 11 I assume it's some sort of strange memory problem, but other than that I really have no clue what's going on.
Here's the activity:
public class TransactionDetailActivity extends CommonActivity implements Animation.AnimationListener {
private TransactionDetail _transaction = null;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.transaction_detail);
getActionBar().setDisplayHomeAsUpEnabled(true);
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
if (mapFragment.getMap() != null) { // can be null if google play services isn't installed
mapFragment.getMap().getUiSettings().setZoomControlsEnabled(false);
}
Intent intent = getIntent();
String transactionReceiptNumber = intent.getStringExtra("transactionReceiptNumber");
loadTransactionDetail(transactionReceiptNumber);
ClipDialog.showDialog(this, getString(R.string.transaction_detail_loading));
}
#Override
public void onPause() {
super.onPause();
if (_runAnimation) {
final ImageView mapScreenshot = (ImageView) findViewById(R.id.map_screenshot);
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
if (mapFragment.getMap() != null) {
mapFragment.getMap().snapshot(new GoogleMap.SnapshotReadyCallback() {
#Override
public void onSnapshotReady(Bitmap snapshot) {
mapScreenshot.setImageBitmap(snapshot);
Bitmap screenshot = Rotate3dAnimation.takeScreenshot(TransactionDetailActivity.this);
ImageView imageView = (ImageView) findViewById(R.id.screenshot);
imageView.setImageBitmap(screenshot);
findViewById(R.id.container).setVisibility(View.GONE);
disableActionBarAnimation();
getActionBar().hide();
imageView.startAnimation(new Rotate3dAnimation(false));
}
});
}
}
}
#Override
public void onResume() {
super.onResume();
if (_runAnimation) {
View imageView = findViewById(R.id.screenshot);
if (imageView != null) {
Rotate3dAnimation anim = new Rotate3dAnimation(true);
anim.setAnimationListener(this);
imageView.startAnimation(anim);
}
_runAnimation = false;
}
}
#Override
public void onAnimationEnd(Animation animation) {
ImageView mapScreenshot = (ImageView) findViewById(R.id.map_screenshot);
mapScreenshot.setImageBitmap(null);
ImageView imageView = (ImageView) findViewById(R.id.screenshot);
imageView.setImageBitmap(null);
findViewById(R.id.container).setVisibility(View.VISIBLE);
disableActionBarAnimation();
getActionBar().show();
}
private void loadTransactionDetail(String receiptNumber) {
ClipAPIClient.getInstance().getAPI().transactionDetail(ClipDataManager.getInstance().getCurrentUser().merchant.id, receiptNumber, new Callback() {
#Override
public void success(Object object, Response response) {
_transaction = (TransactionDetail) object;
configureViewForTransaction();
ClipDialog.hideDialog();
}
#Override
public void failure(RetrofitError error) {
ClipDialog.showDialogForDuration(TransactionDetailActivity.this, getString(R.string.transaction_detail_error));
L.e(error, "Transaction detail error");
AnalyticsClient.logError("TransactionDetail", error);
}
});
}
private void configureViewForTransaction() {
findViewById(R.id.map_container).setVisibility(View.VISIBLE);
findViewById(R.id.scroll_view).setVisibility(View.VISIBLE);
LatLng coordinate = new LatLng(new Double(_transaction.latitude), new Double(_transaction.longitude));
MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
if (mapFragment.getMap() != null) { // can be null if google play services isn't installed
mapFragment.getMap().addMarker(new MarkerOptions().position(coordinate));
mapFragment.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(coordinate, 14));
}
}
}
Here's the xml involving the map fragment:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
>
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#f8f8f8"
>
<FrameLayout
android:id="#+id/map_container"
android:layout_width="match_parent"
android:layout_height="100dip"
android:layout_marginTop="?android:attr/actionBarSize"
android:visibility="gone"
>
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"
/>
<ImageView
android:id="#+id/map_screenshot"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
And here's the logcat:
I/ActivityManager( 3638): Timeline: Activity_launch_request id:com.payclip.clip time:64253930
I/ActivityManager( 478): START u0 {cmp=com.payclip.clip/.activities.TransactionDetailActivity (has extras)} from pid 3638
W/AudioTrack( 478): AUDIO_OUTPUT_FLAG_FAST denied by client due to mismatching sample rate (48000 vs 44100)
I/Google Maps Android API( 3638): Google Play services client version: 3225100
I/Google Maps Android API( 3638): Google Play services package version: 4452036
I/fpp ( 3638): Making Creator dynamically
I/Google Maps Android API( 3638): Google Play services client version: 4452000
F/libc ( 3638): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 3694 (DataRequestDisp)
D/Retrofit( 3638): ---> HTTP GET https://devapitest02.payclip.com/payments/history/detail?merchant_id=3fb182ea-58cb-4d7f-a1b2-6c6088beab8c&receipt_no=NHPiZdY
D/Retrofit( 3638): Cookie: X-Blitz-Auth=MWQyN2M4NDgtYzgwYy00NmIyLWJkN2ItMTRhYWNhZjMxZTUx|1401984427|c4fe537b618705f306119435e3557734cf07eea1
D/Retrofit( 3638): ---> END HTTP (0-byte body)
I/DEBUG ( 129): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 129): Build fingerprint: 'google/mysid/toro:4.2.2/JDQ39/573038:user/release-keys'
I/DEBUG ( 129): Revision: '9'
I/DEBUG ( 129): pid: 3638, tid: 3694, name: DataRequestDisp >>> com.payclip.clip <<<
I/DEBUG ( 129): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG ( 129): r0 00000000 r1 00000000 r2 608d404d r3 00000019
I/DEBUG ( 129): r4 00000008 r5 608d404e r6 00000000 r7 ffffffff
I/DEBUG ( 129): r8 00000001 r9 40adff50 sl 00000019 fp 608d404d
I/DEBUG ( 129): ip 5c153b34 sp 63b87910 lr 5c148099 pc 40acaeae cpsr 600f0030
I/DEBUG ( 129): d0 0000000000000000 d1 0000000000000000
I/DEBUG ( 129): d2 0000000000000000 d3 0000000000000000
I/DEBUG ( 129): d4 c0000c66506245fe d5 0000000032000007
I/DEBUG ( 129): d6 000b0000010001ff d7 0023000201000304
I/DEBUG ( 129): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 129): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 129): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 129): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 129): d16 0000000000000000 d17 0000000000000000
I/DEBUG ( 129): d18 3cf0ec89e8959053 d19 36d009d3948721ab
I/DEBUG ( 129): d20 0000000000ffffff d21 0000000000000005
I/DEBUG ( 129): d22 0000000009000000 d23 bebbb7c504f41aab
I/DEBUG ( 129): d24 3e7ad7f29abcaf48 d25 3ff0000000000000
I/DEBUG ( 129): d26 0000000000000000 d27 0000000000000001
I/DEBUG ( 129): d28 bf8dd78e85b24937 d29 3e2d38fc57f240cc
I/DEBUG ( 129): d30 bfc67dae64a5e000 d31 3fc5528670f6093a
I/DEBUG ( 129): scr 60000013
I/DEBUG ( 129):
I/DEBUG ( 129): backtrace:
I/DEBUG ( 129): #00 pc 00026eae /system/lib/libssl.so (SSL_select_next_proto+49)
I/DEBUG ( 129): #01 pc 00007095 /system/lib/libjavacrypto.so
I/DEBUG ( 129): #02 pc 0002f223 /system/lib/libssl.so (ssl_parse_serverhello_tlsext+434)
I/DEBUG ( 129): #03 pc 000180dd /system/lib/libssl.so (ssl3_get_server_hello+1008)
I/DEBUG ( 129): #04 pc 000174d5 /system/lib/libssl.so (ssl3_connect+564)
I/DEBUG ( 129): #05 pc 00026471 /system/lib/libssl.so (SSL_connect+20)
I/DEBUG ( 129): #06 pc 0001201d /system/lib/libssl.so (ssl23_connect+2292)
I/DEBUG ( 129): #07 pc 00027c27 /system/lib/libssl.so (SSL_do_handshake+50)
I/DEBUG ( 129): #08 pc 0000aeaf /system/lib/libjavacrypto.so
I/DEBUG ( 129): #09 pc 0001ea50 /system/lib/libdvm.so (dvmPlatformInvoke+116)
I/DEBUG ( 129): #10 pc 0004f667 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
I/DEBUG ( 129): #11 pc 00027ee0 /system/lib/libdvm.so
I/DEBUG ( 129): #12 pc 0002f3d8 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
I/DEBUG ( 129): #13 pc 0002ca7c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
I/DEBUG ( 129): #14 pc 00061ae3 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+338)
I/DEBUG ( 129): #15 pc 00061b07 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
I/DEBUG ( 129): #16 pc 000567f3 /system/lib/libdvm.so
I/DEBUG ( 129): #17 pc 0000d248 /system/lib/libc.so (__thread_entry+72)
I/DEBUG ( 129): #18 pc 0000d3e0 /system/lib/libc.so (pthread_create+240)
I/DEBUG ( 129):
I/DEBUG ( 129): stack:
I/DEBUG ( 129): 63b878d0 40243d77 /system/lib/libandroid_runtime.so
I/DEBUG ( 129): 63b878d4 0d427cfb
I/DEBUG ( 129): 63b878d8 00000002
I/DEBUG ( 129): 63b878dc 5c147fd1 /system/lib/libjavacrypto.so
I/DEBUG ( 129): 63b878e0 00000002
I/DEBUG ( 129): 63b878e4 5c147fd1 /system/lib/libjavacrypto.so
I/DEBUG ( 129): 63b878e8 00000003
I/DEBUG ( 129): 63b878ec 40a9be64 /system/lib/libcrypto.so
I/DEBUG ( 129): 63b878f0 401fa1b8
I/DEBUG ( 129): 63b878f4 40a9be64 /system/lib/libcrypto.so
I/DEBUG ( 129): 63b878f8 5ef837b8
I/DEBUG ( 129): 63b878fc 401bcf37 /system/lib/libc.so (dlmalloc+4250)
I/DEBUG ( 129): 63b87900 00000003
I/DEBUG ( 129): 63b87904 00020384
I/DEBUG ( 129): 63b87908 401bbe9d /system/lib/libc.so (dlmalloc)
I/DEBUG ( 129): 63b8790c 00000003
I/DEBUG ( 129): #00 63b87910 40a9be64 /system/lib/libcrypto.so
I/DEBUG ( 129): 63b87914 63b87990
I/DEBUG ( 129): 63b87918 63b8798c
I/DEBUG ( 129): 63b8791c 608d404d
I/DEBUG ( 129): 63b87920 00000019
I/DEBUG ( 129): 63b87924 608d404d
I/DEBUG ( 129): 63b87928 578d1bc0
I/DEBUG ( 129): 63b8792c 63b8798c
I/DEBUG ( 129): 63b87930 63b87990
I/DEBUG ( 129): 63b87934 5ef83598
I/DEBUG ( 129): 63b87938 40adff50 /system/lib/libssl.so
I/DEBUG ( 129): 63b8793c 00000019
I/DEBUG ( 129): 63b87940 608d4049
I/DEBUG ( 129): 63b87944 5c148099 /system/lib/libjavacrypto.so
I/DEBUG ( 129): #01 63b87948 00000000
I/DEBUG ( 129): 63b8794c ffffffff
I/DEBUG ( 129): 63b87950 608d4066
I/DEBUG ( 129): 63b87954 63b879c8
I/DEBUG ( 129): 63b87958 63b879c8
I/DEBUG ( 129): 63b8795c 608d404d
I/DEBUG ( 129): 63b87960 00003374
I/DEBUG ( 129): 63b87964 40ad3225 /system/lib/libssl.so (ssl_parse_serverhello_tlsext+436)
I/DEBUG ( 129): #02 63b87968 00000019
I/DEBUG ( 129): 63b8796c 00000000
I/DEBUG ( 129): 63b87970 40adb4a5 /system/lib/libssl.so
I/DEBUG ( 129): 63b87974 00000001
I/DEBUG ( 129): 63b87978 00000001
I/DEBUG ( 129): 63b8797c 63b879cc
I/DEBUG ( 129): 63b87980 608d4062
I/DEBUG ( 129): 63b87984 608d4066
I/DEBUG ( 129): 63b87988 5ef83598
I/DEBUG ( 129): 63b8798c 5d907490
I/DEBUG ( 129): 63b87990 40a99dc0 /system/lib/libcrypto.so
I/DEBUG ( 129): 63b87994 5ef83598
I/DEBUG ( 129): 63b87998 0000005a
I/DEBUG ( 129): 63b8799c 608d400c
I/DEBUG ( 129): 63b879a0 5d9076a8
I/DEBUG ( 129): 63b879a4 608d402f
I/DEBUG ( 129): ........ ........
I/DEBUG ( 129):
I/DEBUG ( 129): memory near r2:
I/DEBUG ( 129): 608d402c c0000c66 32000007 00000000 010001ff
I/DEBUG ( 129): 608d403c 000b0000 01000304 00230002 00743300
I/DEBUG ( 129): 608d404c 70730819 332f7964 7306312e 2f796470
I/DEBUG ( 129): 608d405c 74680833 312f7074 0000312e 00000000
I/DEBUG ( 129): 608d406c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d407c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d408c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d409c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ac 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40bc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40cc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40dc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ec 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40fc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d410c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d411c 00000000 00000000 00000000 00000000
I/DEBUG ( 129):
I/DEBUG ( 129): memory near r5:
I/DEBUG ( 129): 608d402c c0000c66 32000007 00000000 010001ff
I/DEBUG ( 129): 608d403c 000b0000 01000304 00230002 00743300
I/DEBUG ( 129): 608d404c 70730819 332f7964 7306312e 2f796470
I/DEBUG ( 129): 608d405c 74680833 312f7074 0000312e 00000000
I/DEBUG ( 129): 608d406c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d407c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d408c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d409c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ac 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40bc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40cc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40dc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ec 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40fc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d410c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d411c 00000000 00000000 00000000 00000000
I/DEBUG ( 129):
I/DEBUG ( 129): memory near r9:
I/DEBUG ( 129): 40adff30 00000040 00000020 00000002 00000002
I/DEBUG ( 129): 40adff40 00000105 0000c030 00000000 00000000
I/DEBUG ( 129): 40adff50 00000001 40ad6440 0300c007 00000080
I/DEBUG ( 129): 40adff60 00000040 00000004 00000002 00000002
I/DEBUG ( 129): 40adff70 00000041 0000c030 00000080 00000080
I/DEBUG ( 129): 40adff80 00000001 40ad6454 0300c008 00000080
I/DEBUG ( 129): 40adff90 00000040 00000002 00000002 00000002
I/DEBUG ( 129): 40adffa0 00000181 0000c030 000000a8 000000a8
I/DEBUG ( 129): 40adffb0 00000001 40ad646d 0300c009 00000080
I/DEBUG ( 129): 40adffc0 00000040 00000040 00000002 00000002
I/DEBUG ( 129): 40adffd0 00000181 0000c030 00000080 00000080
I/DEBUG ( 129): 40adffe0 00000001 40ad6484 0300c00a 00000080
I/DEBUG ( 129): 40adfff0 00000040 00000080 00000002 00000002
I/DEBUG ( 129): 40ae0000 00000181 0000c030 00000100 00000100
I/DEBUG ( 129): 40ae0010 00000001 40ad649b 0300c00b 00000020
I/DEBUG ( 129): 40ae0020 00000010 00000020 00000002 00000002
I/DEBUG ( 129):
I/DEBUG ( 129): memory near fp:
I/DEBUG ( 129): 608d402c c0000c66 32000007 00000000 010001ff
I/DEBUG ( 129): 608d403c 000b0000 01000304 00230002 00743300
I/DEBUG ( 129): 608d404c 70730819 332f7964 7306312e 2f796470
I/DEBUG ( 129): 608d405c 74680833 312f7074 0000312e 00000000
I/DEBUG ( 129): 608d406c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d407c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d408c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d409c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ac 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40bc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40cc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40dc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40ec 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d40fc 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d410c 00000000 00000000 00000000 00000000
I/DEBUG ( 129): 608d411c 00000000 00000000 00000000 00000000
I/DEBUG ( 129):
I/DEBUG ( 129): memory near ip:
I/DEBUG ( 129): 5c153b14 40a319e5 409f5a8d 40a2812d 40a27dd1
I/DEBUG ( 129): 5c153b24 40a28b25 40a20e65 40a2c10d 401bf0cd
I/DEBUG ( 129): 5c153b34 40acae7d 401ba8a8 401ba9ac 40a3f3d5
I/DEBUG ( 129): 5c153b44 40aca6fd 40158927 40186559 401295b5
I/DEBUG ( 129): 5c153b54 40a34491 40a2cded 40a2cc61 40a2cc01
I/DEBUG ( 129): 5c153b64 40a2d169 40a2f1f9 401d178d 40a2f1d9
I/DEBUG ( 129): 5c153b74 40a2f2bd 401b9cd1 401bf4a5 401bdfc5
I/DEBUG ( 129): 5c153b84 401296f5 40acaef9 40acddb1 40a66cd5
I/DEBUG ( 129): 5c153b94 409ff4b9 409ff5a1 40a66d1d 40a0271d
I/DEBUG ( 129): 5c153ba4 409f8991 409fb1a1 40a66475 40a5a135
I/DEBUG ( 129): 5c153bb4 40a01189 40a049b1 40a34dc1 40a04a55
I/DEBUG ( 129): 5c153bc4 409f48b5 40a35405 40a25345 40a25695
I/DEBUG ( 129): 5c153bd4 40a24ec5 40a250c9 40a254e1 40a24e4d
I/DEBUG ( 129): 5c153be4 40a252dd 40a3f279 40a252e9 40a252e1
I/DEBUG ( 129): 5c153bf4 40a251cd 40a36b09 40a36a0d 40a36e41
I/DEBUG ( 129): 5c153c04 409f5a95 40a2578d 409f3951 409fea55
I/DEBUG ( 129):
I/DEBUG ( 129): memory near sp:
I/DEBUG ( 129): 63b878f0 401fa1b8 40a9be64 5ef837b8 401bcf37
I/DEBUG ( 129): 63b87900 00000003 00020384 401bbe9d 00000003
I/DEBUG ( 129): 63b87910 40a9be64 63b87990 63b8798c 608d404d
I/DEBUG ( 129): 63b87920 00000019 608d404d 578d1bc0 63b8798c
I/DEBUG ( 129): 63b87930 63b87990 5ef83598 40adff50 00000019
I/DEBUG ( 129): 63b87940 608d4049 5c148099 00000000 ffffffff
I/DEBUG ( 129): 63b87950 608d4066 63b879c8 63b879c8 608d404d
I/DEBUG ( 129): 63b87960 00003374 40ad3225 00000019 00000000
I/DEBUG ( 129): 63b87970 40adb4a5 00000001 00000001 63b879cc
I/DEBUG ( 129): 63b87980 608d4062 608d4066 5ef83598 5d907490
I/DEBUG ( 129): 63b87990 40a99dc0 5ef83598 0000005a 608d400c
I/DEBUG ( 129): 63b879a0 5d9076a8 608d402f 40adff50 00000000
I/DEBUG ( 129): 63b879b0 00001110 40abc0e1 63b879c8 63b879c4
I/DEBUG ( 129): 63b879c0 5ef83598 00000001 5c1481f9 608d4032
I/DEBUG ( 129): 63b879d0 5ef83598 00001120 5c1481f9 5c1481f9
I/DEBUG ( 129): 63b879e0 00000000 00001120 00001000 40abb4d9
I/DEBUG ( 129):
I/DEBUG ( 129): code around pc:
I/DEBUG ( 129): 40acae8c d02c2b00 9f0f9701 21009102 4001f81b
I/DEBUG ( 129): 40acae9c 0801f101 eb0bb1cf eb0b0001 90030508
I/DEBUG ( 129): 40acaeac f8162000 f1009000 454c0a01 eb06d109
I/DEBUG ( 129): 40acaebc 4628010a f7e54622 4601efcc 29002001
I/DEBUG ( 129): 40acaecc eb0ad00a 42b80009 9a04d3eb 0104eb08
I/DEBUG ( 129): 40acaedc 42912002 e000d3da 99029e03 1c729f01
I/DEBUG ( 129): 40acaeec 7832603a b005700a 8ff0e8bd 3178f8d0
I/DEBUG ( 129): 40acaefc 600b2b00 0100f04f f890bf18 6011117c
I/DEBUG ( 129): 40acaf0c bf004770 11a4f8c0 21a8f8c0 bf004770
I/DEBUG ( 129): 40acaf1c 11acf8c0 21b0f8c0 bf004770 4605b570
I/DEBUG ( 129): 40acaf2c f8d54614 460e01bc f7e5b108 490cee42
I/DEBUG ( 129): 40acaf3c 6296f240 44794809 46204401 ee2cf7e5
I/DEBUG ( 129): 40acaf4c f8c52101 b13001bc 46224631 ee6cf7e5
I/DEBUG ( 129): 40acaf5c f8c52100 460841c0 bf00bd70 ffffb4ae
I/DEBUG ( 129): 40acaf6c 00013b02 4605b570 f8d54614 460e019c
I/DEBUG ( 129): 40acaf7c f7e5b108 490cee1e 62aaf240 44794809
I/DEBUG ( 129):
I/DEBUG ( 129): code around lr:
I/DEBUG ( 129): 5c148078 46402300 f7fe2121 6a6aef9a b13c6aab
I/DEBUG ( 129): 5c148088 000ce88d 46314638 9b084622 ef76f7fe
I/DEBUG ( 129): 5c148098 e8bd2000 b53881fc b1884604 b1556a05
I/DEBUG ( 129): 5c1480a8 ffccf7ff 68296803 47906d9a f7fe4628
I/DEBUG ( 129): 5c1480b8 2000ef84 21006220 60e12001 bd386161
I/DEBUG ( 129): 5c1480c8 b508bd38 6d5a6803 bd084790 6803b508
I/DEBUG ( 129): 5c1480d8 47906dda b508bd08 6fda6803 bd084790
I/DEBUG ( 129): 5c1480e8 6804b510 4084f8d4 bd1047a0 b513b40c
I/DEBUG ( 129): 5c1480f8 6804ab04 2b04f853 40c8f8d4 47a09301
I/DEBUG ( 129): 5c148108 401ce8bd 4770b002 b513b40c 6804ab04
I/DEBUG ( 129): 5c148118 2b04f853 40f8f8d4 47a09301 401ce8bd
I/DEBUG ( 129): 5c148128 4770b002 b513b40c 6804ab04 2b04f853
I/DEBUG ( 129): 5c148138 41ccf8d4 47a09301 401ce8bd 4770b002
I/DEBUG ( 129): 5c148148 6803b508 229cf8d3 bd084790 6803b508
I/DEBUG ( 129): 5c148158 22acf8d3 bd084790 6804b510 42b0f8d4
I/DEBUG ( 129): 5c148168 bd1047a0 6803b508 32b4f8d3 bd084798
I/BootReceiver( 478): Copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE)
W/ActivityManager( 478): Force finishing activity com.payclip.clip/.activities.TransactionDetailActivity
W/ActivityManager( 478): Force finishing activity com.payclip.clip/.activities.TransactionHistoryActivity
I/WindowState( 478): WIN DEATH: Window{41e898d0 u0 com.payclip.clip/com.payclip.clip.activities.AmountActivity}
I/WindowState( 478): WIN DEATH: Window{421551e8 u0 Panel:com.payclip.clip/com.payclip.clip.activities.TransactionHistoryActivity}
I/WindowState( 478): WIN DEATH: Window{421d9b40 u0 com.payclip.clip/com.payclip.clip.activities.TransactionDetailActivity}
I/WindowState( 478): WIN DEATH: Window{423ecf60 u0 com.payclip.clip/com.payclip.clip.activities.TransactionDetailActivity}
I/WindowState( 478): WIN DEATH: Window{4214a618 u0 com.payclip.clip/com.payclip.clip.activities.TransactionHistoryActivity}
I/ActivityManager( 478): Process com.payclip.clip (pid 3638) has died.
V/Zygote ( 3701): Switching descriptor 32 to /dev/null
V/Zygote ( 3701): Switching descriptor 9 to /dev/null
D/dalvikvm( 3701): Late-enabling CheckJNI
D/Zygote ( 132): Process 3638 terminated by signal (11)
On a 4.4.2 tablet, which doesn't crash, this is what shows after the view is all loaded:
D/dalvikvm(27019): GC_FOR_ALLOC freed 1137K, 14% free 12105K/14048K, paused 25ms, total 25ms
So it turns out that the crash was caused by an SSL error. I was using an older version of Retrofit that was causing bugs with not only google maps, but also with a Webview. The solution was to upgrade to the latest version of retrofit. Thanks for the suggestions.
I have an Android App, in which I have below class containing fields of both native (C++) objects wrapped with JNI, and other java objects:
class MyClass
{
Node nativeNode; // containing Native objects wrapped using NDK and JNI
long otherVars; // some java instances
public void dispose()
{
freeNativeNode();
}
}
In my app, I continuously create instances of MyClass:
for(int i=0;i<1000;i++)
{
MyClass obj = new MyClass();
...
obj.freeNativeNode(); // Here, free native resources (A)
//System.gc(); // Here explicitly collect memory (B)
}
The app crashes when i is bigger than some number, e.g. when i>400 or i>450.
Since I have freed the native memory explicitly as in line (A) above, so I think there should be no memory leak, and java shall use garbage collection to revoke the memory. But the app crashes, and I suspect it might be a memory leak problem.
As I know, it is possible to free the managed memory in Java by calling:
System.GC();
I tried to call this in (B) above, however, the app crashes more often, and say when i > 60, it already crashes.
My questions are:
[1] Should I call System.GC() explicitly? As many have different opinions on calling this ourselves, and some say this is not a good practice.
[2] How do I elegantly free the memory in the loop to avoid crash?
Edit: I understand it is less appropriate to print full log here, but it might be useful to get the whole picture for troubleshooting the problem.
From the log, it seems to be not a memory leak problem, but one of my colleague believes so, and I have no strong evidence showing this is NOT, :)
The tombstone log: debuggerd: 2014-05-01 23:56:47
Build fingerprint: 'htc_asia_hk/endeavoru/endeavoru:4.1.1/JRO03C/128187.28:user/release-keys'
pid: 31725, tid: 31725, name: com.cityu.scm >>> com.cityu.scm <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000003
r0 000ff7ff r1 ffffffff r2 00000000 r3 ffffffff
r4 00000110 r5 553b36f8 r6 00000008 r7 00000000
r8 00000000 r9 48ce1c44 sl 40c5b020 fp bec7761c
ip 00000110 sp bec76db0 lr 400491b7 pc 400497b6 cpsr a0000030
d0 0000000000000008 d1 3ddb7cdfd9d7bdbb
d2 3fece61cf8e1788d d3 4435800000000000
d4 000002d0000002d6 d5 0000000042000000
d6 44340000435f0000 d7 0000000040000000
d8 00000000440a8000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 0000000000000000 d17 0000000000000001
d18 0000000000000000 d19 3ff0000000000000
d20 0000000000000000 d21 0000000000000000
d22 0000000000000000 d23 0000000000000000
d24 3ff0000000000000 d25 3ff0000000000000
d26 0000000000000000 d27 c053000000000000
d28 0000000000000006 d29 3ff0000000000000
d30 3ff0000000000000 d31 3ff0000000000000
scr 20000011
backtrace:
#00 pc 000147b6 /system/lib/libc.so (dlmalloc+1589)
#01 pc 00017123 /system/lib/libc.so (malloc+10)
#02 pc 003774fc /data/data/com.cityu.scm/lib/libjniosg.so (operator new(unsigned int)+24)
stack:
bec76d70 5516df70
bec76d74 bec77608 [stack]
bec76d78 48ce1c44
bec76d7c 40c5b020
bec76d80 c0000000
bec76d84 0000001b
bec76d88 0000000e
bec76d8c 003ef75c
bec76d90 0000000e
bec76d94 bec77310 [stack]
bec76d98 c0000000
bec76d9c 00000108
bec76da0 00000000
bec76da4 003ef75c
bec76da8 df0027ad
bec76dac 00000000
#00 bec76db0 524af370
bec76db4 53dc0677 /data/data/com.cityu.scm/lib/libjniosg.so
bec76db8 00000000
bec76dbc 53dc0b15 /data/data/com.cityu.scm/lib/libjniosg.so
(std::_Rb_tree >, std::_Select1st > >, std::less, std::allocator > > >::find(std::string const&)+58)
bec76dc0 00000000
bec76dc4 00000108
bec76dc8 524af160
bec76dcc 003ef75c
bec76dd0 00000164
bec76dd4 bec77608 [stack]
bec76dd8 48ce1c44
bec76ddc 40c5b020
bec76de0 bec7761c [stack]
bec76de4 4004c125 /system/lib/libc.so (malloc+12)
#01 bec76de8 53cbd8ad /data/data/com.cityu.scm/lib/libjniosg.so
bec76dec 53c09500 /data/data/com.cityu.scm/lib/libjniosg.so (operator new(unsigned int)+28)
#02 bec76df0 00000000
bec76df4 524af160
bec76df8 bec7724c [stack]
bec76dfc 53cbd8b7 /data/data/com.cityu.scm/lib/libjniosg.so
bec76e00 00000000
bec76e04 53dc5af9 /data/data/com.cityu.scm/lib/libjniosg.so
(osgDB::InputStream::readObjectFields(std::string const&, unsigned int, osg::Object*)+80)
bec76e08 bec76e34 [stack]
bec76e0c 00000009
bec76e10 bec7724c [stack]
bec76e14 53c1a70b /data/data/com.cityu.scm/lib/libjniosg.so
(BinaryInputIterator::readUInt(unsigned int&)+14)
bec76e18 bec7724c [stack]
bec76e1c bec77288 [stack]
bec76e20 bec7724c [stack]
bec76e24 bec7724c [stack]
bec76e28 00000000
bec76e2c 53dc5c53 /data/data/com.cityu.scm/lib/libjniosg.so
(osgDB::InputStream::readObject(osg::Object*)+114)
memory near r0:
000ff7dc ffffffff ffffffff ffffffff ffffffff ................
000ff7ec ffffffff ffffffff ffffffff ffffffff ................
000ff7fc ffffffff ffffffff ffffffff ffffffff ................
000ff80c ffffffff ffffffff ffffffff ffffffff ................
000ff81c ffffffff ffffffff ffffffff ffffffff ................
memory near r5:
553b36d8 00000000 00000000 53ffa940 553b3701 ........#..S.7;U
553b36e8 00000000 00000000 00000000 00000000 ................
553b36f8 00000000 00000111 553b15f0 553b0b68 ..........;Uh.;U
553b3708 ffffffff 00000000 524133b8 00000000 .........3AR....
553b3718 00000020 000000f1 552da1d0 552fd620 .........-U ./U
memory near r9:
48ce1c24 4cdbee30 4bc88be8 00000006 48ce1c5c 0..L...K....\..H
48ce1c34 5270279c 4bff8370 00000006 00000000 .'pRp..K........
48ce1c44 4390001d 48ce1c84 526f0310 4bff83a8 ...C...H..oR...K
48ce1c54 5270279c 00000000 48ce1c84 526f0308 .'pR.......H..oR
48ce1c64 4bc81c28 00000006 410ace98 48ce1cbc (..K.......A...H
memory near sl:
40c5b000 00000000 00000000 00000000 00000453 ............S...
40c5b010 4cd06328 48ce1c44 4bff83a8 52486000 (c.LD..H...K.`HR
40c5b020 8b300dd1 00001d30 bec77730 00000000 ..0.0...0w......
40c5b030 bec77764 00000001 00000000 40791380 dw............y#
40c5b040 00000000 00000000 402e0570 48cdc300 ........p..#...H
memory near fp:
bec775fc 54f4c024 4bff8370 407911f4 48ce1c44 $..Tp..K..y#D..H
bec7760c 00000001 4119d1f8 52722f8f 0000003b .......A./rR;...
bec7761c 407c3c87 48ce1c44 52722f8d 53bc6a01 .<|#D..H./rR.j.S
bec7762c 40c5b020 a3a00019 00000000 4082c238 ..#........8..#
bec7763c 40085a98 00000022 40103033 40cdbb10 .Z.#"...30.#...#
memory near sp:
bec76d90 0000000e bec77310 c0000000 00000108 .....s..........
bec76da0 00000000 003ef75c df0027ad 00000000 ....\.>..'......
bec76db0 524af370 53dc0677 00000000 53dc0b15 p.JRw..S.......S
bec76dc0 00000000 00000108 524af160 003ef75c ........`.JR\.>.
bec76dd0 00000164 bec77608 48ce1c44 40c5b020 d....v..D..H ..#
code around pc:
40049794 0240f3c0 66a8f8df f102fa30 0c02eb03 ..#....f0.......
400497a4 0501eb0c eb06447e 25000085 312cf8d0 ....~D.....%..,1
400497b4 685ae00d f0226919 ebc40c03 4542020c ..Zh.i".......BE
400497c4 4642bf2c b901461d 460b6959 2b004690 ,.BF.F..Yi.F.F.+
400497d4 2d00d1ef 818ff000 2668f8df 6890447a ...-......h&zD.h
code around lr:
40049194 b930fd11 2becf8df f8d2447a 078b11b4 ..0....+zD......
400491a4 f8dfd50a 447d5be4 70dcf505 f7fe2500 .....[}D...p.%..
400491b4 2800e886 8249f041 f2002cf4 2c0a823f ...(A.I..,..?..,
400491c4 340bd903 0407f024 2410e000 7bbcf8df ...4$......$...{
400491d4 447f08e2 fa36683e 079df302 f003d042 ...D>h6.....B...
pid: 31725, tid: 31727, name: GC
r0 fffffffc r1 00000080 r2 fffffffc r3 4fe62e30
r4 40cdbbb0 r5 40cdbbac r6 fffffffc r7 000000f0
r8 00001388 r9 00000000 sl 4082df98 fp 00000001
ip 00000000 sp 4fe62e10 lr 40047f80 pc 40042ca4 cpsr 60000010
d0 42c80000428cea01 d1 3ff00000003db190
d2 0000000100000001 d3 b684088000080000
d4 0000000040dc8000 d5 000000000006e400
d6 00578fe000000963 d7 000000464dc0cae2
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 4139200000000000 d17 4132d9f000000000
d18 0033003200310030 d19 0000000000000000
d20 4008000000000000 d21 3fbc71c71c71c71c
d22 3fcc7288e957b53b d23 3fd24998d6307188
d24 3fd99a27ad32ddf5 d25 3fe555b0aaeac752
d26 0000000000000000 d27 0000000000000000
d28 0000000000000005 d29 0000000000000000
d30 0000000000000000 d31 0000000000000000
scr 80000010
backtrace:
#00 pc 0000dca4 /system/lib/libc.so (__futex_syscall3+12)
#01 pc 00012f7c /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012fd8 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 00057029 /system/lib/libdvm.so (dvmRelativeCondWait(pthread_cond_t*, pthread_mutex_t*, long long, int)+112)
#04 pc 00078655 /system/lib/libdvm.so
#05 pc 000591e7 /system/lib/libdvm.so
#06 pc 00012e48 /system/lib/libc.so (__thread_entry+72)
#07 pc 0001257c /system/lib/libc.so (pthread_create+208)
stack:
4fe62dd0 01e9b4a6
4fe62dd4 7fffffff
4fe62dd8 01e9b50c
4fe62ddc 0004e200
4fe62de0 0000fa00
4fe62de4 40046314 /system/lib/libc.so (__divdi3+244)
4fe62de8 01e9b517
4fe62dec 4082c238 /system/lib/libdvm.so
4fe62df0 40cdbab0 [heap]
4fe62df4 00000000
4fe62df8 4fe62e00
4fe62dfc 000003e8
4fe62e00 00000000
4fe62e04 00001388
4fe62e08 00000000
4fe62e0c 00001388
#00 4fe62e10 40cdbbb0 [heap]
4fe62e14 4fe62e30
#01 4fe62e18 00000001
4fe62e1c 40cdbbac [heap]
4fe62e20 40cdbbb0 [heap]
4fe62e24 40cdbbb0 [heap]
4fe62e28 40cdbbac [heap]
4fe62e2c 40047fdc /system/lib/libc.so (__pthread_cond_timedwait+64)
#02 4fe62e30 00000004
4fe62e34 3b9ac618
4fe62e38 4fe62e40
4fe62e3c 1c09ac61
4fe62e40 00007d62
4fe62e44 407ca02d /system/lib/libdvm.so (dvmRelativeCondWait(pthread_cond_t*, pthread_mutex_t*, long long, int)+116)
#03 4fe62e48 00007d62
4fe62e4c 1c09ac61
4fe62e50 00001388
4fe62e54 407eb765 /system/lib/libdvm.so
4fe62e58 4082df98
4fe62e5c 00000000
4fe62e60 00000001
4fe62e64 407cc19d /system/lib/libdvm.so
4fe62e68 00100000
4fe62e6c 407eb659 /system/lib/libdvm.so
#04 4fe62e70 00000000
4fe62e74 00000001
4fe62e78 00000001
4fe62e7c 00000000
4fe62e80 00000008
4fe62e84 40c725e0
4fe62e88 4082c238 /system/lib/libdvm.so
4fe62e8c bec77768 [stack]
4fe62e90 00000078
4fe62e94 407cc19d /system/lib/libdvm.so
4fe62e98 00100000
4fe62e9c 40c725e0
4fe62ea0 00000001
4fe62ea4 407cc1e9 /system/lib/libdvm.so
#05 4fe62ea8 40c725e0
4fe62eac 00010002
4fe62eb0 40ccbc80
4fe62eb4 40cea080 /dev/ashmem/dalvik-heap (deleted)
4fe62eb8 4fe62f00
4fe62ebc 40c725e0
4fe62ec0 407cc190 /system/lib/libdvm.so (dvmDetachCurrentThread()+763)
4fe62ec4 40047e4c /system/lib/libc.so (__thread_entry+76)
#06 4fe62ec8 00000000
4fe62ecc 00000000
4fe62ed0 00000000
4fe62ed4 00000000
4fe62ed8 00000000
4fe62edc 4fe62f00
4fe62ee0 40cce0a0
4fe62ee4 bec77770 [stack]
4fe62ee8 00000078
4fe62eec 407cc19d /system/lib/libdvm.so
4fe62ef0 00100000
4fe62ef4 40c725e0
4fe62ef8 00000001
4fe62efc 40047580 /system/lib/libc.so (pthread_create+212)
#07 4fe62f00 4fe62f00
4fe62f04 40cce0a0
4fe62f08 00000000
4fe62f0c 00000000
4fe62f10 00000000
4fe62f14 00000000
4fe62f18 4e68a460
4fe62f1c 00000000
4fe62f20 00000000
4fe62f24 00000000
4fe62f28 00000000
4fe62f2c 00000000
4fe62f30 00000000
4fe62f34 00000000
4fe62f38 00000000
4fe62f3c 00000000
pid: 31725, tid: 31729, name: Signal Catcher
r0 fffffffc r1 00000000 r2 00000000 r3 00000008
r4 4ff62e58 r5 40828261 r6 bec77778 r7 000000b1
r8 407cc19d r9 52415800 sl 5010be38 fp 00042e74
ip 40827e6c sp 4ff62e18 lr 4004f453 pc 40042554 cpsr 20000010
d0 42c800004266db5b d1 3ff00000002aff38
d2 0000000100000001 d3 b684088000080000
d4 0000000040dc8000 d5 000000000006e400
d6 004a7ff000000963 d7 000000394d865d8f
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 40d3000000000000 d17 40c3cc0000000000
d18 0033003200310030 d19 0000000000000000
d20 4008000000000000 d21 3fbc71c71c71c71c
d22 3fcc7288e957b53b d23 3fd24998d6307188
d24 3fd99a27ad32ddf5 d25 3fe555b0aaeac752
d26 0000000000000000 d27 0000000000000000
d28 0000000000000005 d29 0000000000000000
d30 0000000000000000 d31 0000000000000000
scr 80000010
backtrace:
#00 pc 0000d554 /system/lib/libc.so (__rt_sigtimedwait+12)
#01 pc 0001a44f /system/lib/libc.so (sigwait+20)
#02 pc 00055fcf /system/lib/libdvm.so
#03 pc 000591e7 /system/lib/libdvm.so
#04 pc 00012e48 /system/lib/libc.so (__thread_entry+72)
#05 pc 0001257c /system/lib/libc.so (pthread_create+208)
stack:
4ff62dd8 00000000
4ff62ddc 00000000
4ff62de0 00000000
4ff62de4 00000000
4ff62de8 00000000
4ff62dec 00000000
4ff62df0 40827c88 /system/lib/libdvm.so
4ff62df4 52415800
4ff62df8 4bc64570 /dev/ashmem/dalvik-LinearAlloc (deleted)
4ff62dfc 4ff62e78
4ff62e00 4ff62e78
4ff62e04 40cbffc4
4ff62e08 4ce76760 /system/framework/core.odex
4ff62e0c 4ff62e78
4ff62e10 00000000
4ff62e14 407d9c21 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+276)
#00 4ff62e18 4ff62e58
4ff62e1c 40811cfc /system/lib/libdvm.so
#01 4ff62e20 00000204
4ff62e24 00000000
4ff62e28 5010be38
4ff62e2c 407c8fd3 /system/lib/libdvm.so
#02 4ff62e30 00000001
4ff62e34 40cea080 /dev/ashmem/dalvik-heap (deleted)
4ff62e38 4bc64570 /dev/ashmem/dalvik-LinearAlloc (deleted)
4ff62e3c 40003310
4ff62e40 52415b6c
4ff62e44 407c88ef /system/lib/libdvm.so (dvmRemoveFromReferenceTable(ReferenceTable*, Object**, Object*)+30)
4ff62e48 52415800
4ff62e4c 00042e8a
4ff62e50 410a0ec8 /dev/ashmem/dalvik-heap (deleted)
4ff62e54 00000204
4ff62e58 ffffffe0
4ff62e5c 52415800
4ff62e60 410a0ec8 /dev/ashmem/dalvik-heap (deleted)
4ff62e64 407cb485 /system/lib/libdvm.so (dvmAttachCurrentThread(JavaVMAttachArgs const*, bool)+452)
4ff62e68 40cea080 /dev/ashmem/dalvik-heap (deleted)
4ff62e6c 410a0ec8 /dev/ashmem/dalvik-heap (deleted)
........ ........
#03 4ff62ea8 5010be38
4ff62eac 00010002
4ff62eb0 40c6d380
4ff62eb4 40cea080 /dev/ashmem/dalvik-heap (deleted)
4ff62eb8 4ff62f00
4ff62ebc 5010be38
4ff62ec0 407cc190 /system/lib/libdvm.so (dvmDetachCurrentThread()+763)
4ff62ec4 40047e4c /system/lib/libc.so (__thread_entry+76)
#04 4ff62ec8 00000000
4ff62ecc 00000000
4ff62ed0 00000000
4ff62ed4 00000000
4ff62ed8 00000000
4ff62edc 4ff62f00
4ff62ee0 40cce8f8
4ff62ee4 bec77780 [stack]
4ff62ee8 00000078
4ff62eec 407cc19d /system/lib/libdvm.so
4ff62ef0 00100000
4ff62ef4 5010be38
4ff62ef8 00000001
4ff62efc 40047580 /system/lib/libc.so (pthread_create+212)
#05 4ff62f00 4ff62f00
4ff62f04 40cce8f8
4ff62f08 00000000
4ff62f0c 00000000
4ff62f10 00000000
4ff62f14 00000000
4ff62f18 52415800
4ff62f1c 00000000
4ff62f20 00000000
4ff62f24 00000000
4ff62f28 00000000
4ff62f2c 00000000
4ff62f30 00000000
4ff62f34 00000000
4ff62f38 00000000
4ff62f3c 00000000
pid: 31725, tid: 31730, name: JDWP
r0 00000031 r1 50062de0 r2 00000000 r3 00000000
r4 00000000 r5 00000000 r6 00000000 r7 0000008e
r8 501011b0 r9 00000030 sl 0003b777 fp 00000001
ip 50062dc0 sp 50062db0 lr 407dad43 pc 40041cb4 cpsr 40000010
d0 42c800004266db5b d1 3ff00000002aff38
d2 0000000100000001 d3 b684088000080000
d4 0000000040dc8000 d5 000000000006e400
d6 004a7ff000000963 d7 000000394d865d8f
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 40d3000000000000 d17 40c3cc0000000000
d18 0033003200310030 d19 0000000000000000
d20 4008000000000000 d21 3fbc71c71c71c71c
d22 3fcc7288e957b53b d23 3fd24998d6307188
d24 3fd99a27ad32ddf5 d25 3fe555b0aaeac752
d26 0000000000000000 d27 0000000000000000
d28 0000000000000005 d29 0000000000000000
d30 0000000000000000 d31 0000000000000000
scr 80000010
backtrace:
#00 pc 0000ccb4 /system/lib/libc.so (select+16)
#01 pc 00067d3f /system/lib/libdvm.so
#02 pc 0006acd1 /system/lib/libdvm.so
#03 pc 000591e7 /system/lib/libdvm.so
#04 pc 00012e48 /system/lib/libc.so (__thread_entry+72)
#05 pc 0001257c /system/lib/libc.so (pthread_create+208)
[1] Should I call System.GC() explicitly? As many have different
opinions on calling this ourselves, and some say this is not a good
practice.
Probably not. As previously mentioned by user3580294, System.GC() is really only a suggestion to the VM and what it does when you call that method directly is totally up to the implementation. I would never use this function to prevent a program from crashing.
[2] How do I elegantly free the memory in the loop to avoid crash?
What exactly is using up all the memory? Clearly when MyClass is
constructed some native resouces are being created... Are these JNI
objects? Are they C alloced memory?
I am going to go out on a limb here based on the backtrace and say that the objects eating up all your memory are JNI objects that were created in C/C++ (probably on a separate thread) and passed back to the JVM. Try calling DeleteLocalRef() on the JNI object(s) that are passed back to the VM.
Again, my above suggestion is based on a lot of assumption. You really need to attach a memory profiler like jvisualvm to the JVM to see exactly what is using up all the memory and then determine why the GC didn't catch it. (Hint: there is probably still a reference to it)
I need to change the file name(/system/etc/asound.conf) in android native jni.
I can do this in serial port by run shell cmd:
mount -o remount rw /system
busybox mv /system/etc/asound.conf /system/etc/asoundback.conf
mount -o remount r /system
First, I run above shell script in in java by invoking Runtime.getRuntiem(String). Ihis will result in all android system services reload. So I didn't do like this.
I run above shell script in jni by invoking system() like this:
android_media_AudioSystem_changeFileName(JNIEnv *env, jobject thiz, jstring from, jstring to)
{
const jchar* c_from = env->GetStringCritical(from, 0);
String8 c_from8;
if (from) {
c_from8 = String8(c_from, env->GetStringLength(from));
env->ReleaseStringCritical(from, c_from);
}
const jchar* c_to = env->GetStringCritical(to, 0);
String8 c_to8;
if (to) {
c_to8 = String8(c_to, env->GetStringLength(to));
env->ReleaseStringCritical(to, c_to);
}
LOGV("*********** android_media_AudioSystem_changeFileName from: %s ,to: %s" ,c_from8 ,c_to8);
char buff[4096];
sprintf(buff ,"mount -o remount rw /system;busybox mv %s %s;mount -o remount r /system" ,c_from8 ,c_to8);
if(system(buff) == -1) return -1;
return 0;
}
It does not work. The log is:
[ 197.520000] mclkdiv = 2, bitclkdiv = 12
D/ALSAModule( 1160): open called for devices 00000002 in mode 0...
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker_normal
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback_Speaker
E/ALSALib ( 1160): external/alsa-lib/src/pcm/pcm.c:2203:(snd_pcm_open_noupdate) Unknown PCM AndroidPlayback
I/ALSAModule( 1160): Initialized ALSA PLAYBACK device defaul
D/SoundSettings( 2041): ******* audio channel: codec
D/SoundSettings( 2041): ******* before asound-----> asoundback
I/AudioSystem( 2041): *********** android_media_AudioSystem_changeFileName
F/libc ( 2041): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
I/DEBUG ( 1155): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 1155): Build fingerprint: 'android:4.0.3/IML74K/eng.android.20120717.210618:eng/test-keys'
I/DEBUG ( 1155): pid: 2041, tid: 2041 >>> com.android.settings <<<
I/DEBUG ( 1155): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaadI/DEBUG ( 1155): r0 deadbaad r1 00000001 r2 40000000 r3 00000000
I/DEBUG ( 1155): r4 00000000 r5 00000027 r6 62100021 r7 411afa18
I/DEBUG ( 1155): r8 be9b8644 r9 be9b864c 10 4786445b fp be9b8684
I/DEBUG ( 1155): ip ffffffff sp be9b8618 lr 40068f01 pc 40065660 cpsr 60000030
I/DEBUG ( 1155): #00 pc 00017660 /system/lib/libc.so
I/DEBUG ( 1155): #01 pc 0006f9de /system/lib/libandroid_runtime.so
I/DEBUG ( 1155): #02 pc 0001ebf0 /system/lib/libdvm.so (dvmPlatformInvoke)
I/DEBUG ( 1155): #03 pc 00058c38 /system/lib/libdvm.so (_Z16dvmCallJNIMethodPKjP6JValuePK6MethodP6Thread)
I/DEBUG ( 1155):
I/DEBUG ( 1155): code around pc:
I/DEBUG ( 1155): 40065640 4623b15c 2c006824 e026d1fb b12368db \.#F$h.,..&..h#.
I/DEBUG ( 1155): 40065650 21014a17 6011447a 48124798 24002527 .J.!zD.`.G.H'%.$
I/DEBUG ( 1155): 40065660 f7f47005 2106ef70 effef7f5 460aa901 .p..p..!.......F
I/DEBUG ( 1155): 40065670 f04f2006 94015380 94029303 ebc8f7f5 . O..S..........
I/DEBUG ( 1155): 40065680 4622a905 f7f52002 f7f4ebd2 2106ef5c .."F. ......\..!
I/DEBUG ( 1155):
I/DEBUG ( 1155): code around lr:
I/DEBUG ( 1155): 40068ee0 41f0e92d 46804c0c 447c2600 68a56824 -..A.L.F.&|D$h.h
I/DEBUG ( 1155): 40068ef0 e0076867 300cf9b5 dd022b00 47c04628 gh.....0.+..(F.G
I/DEBUG ( 1155): 40068f00 35544306 37fff117 6824d5f4 d1ee2c00 .CT5...7..$h.,..
I/DEBUG ( 1155): 40068f10 e8bd4630 bf0081f0 000285fa 41f0e92d 0F..........-..A
I/DEBUG ( 1155): 40068f20 fb01b086 9004f602 461f4815 4615460c .........H.F.F.F
I/DEBUG ( 1155):
I/DEBUG ( 1155): memory map around addr deadbaad:
Someelse can help me ? Thanks a lot!!!
I am not an expert in the tracelogs, but from what I can make of it you have :
1. Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1)
this means memory corruption, deadbaad means corrupted memory..
2. I/DEBUG ( 1155): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaadI/DEBUG ( 1155): r0 deadbaad r1 00000001 r2 40000000 r3 00000000
this means the registries are null or 0..
I cannot help further, since I have no idea what you'r doing, but I guess that you are making a wrong read somewhere..