I have a bar-code scanning Cordova (webview) app, and after a certain point, if I restart the barcode-scanning camera, I get a crazy crash that bricks my phone until I give the entire phone a full restart:
Stats:
Nexus 5
Android 4.4.4
Kernel 3.4.0-gd59db4e
I'm using the zbar scanning lib, which uses OpenCV.
Here's the catlog right around the time that things go haywire; once I start getting "Failed to get_buf", the repeating image effect kicks in and I have to restart my phone.
D/mm-camera(199): module_faceproc_port_event_func:667] FD_STREAMON for stream 10004
I/mm-camera(199): cpp_module_handle_streamon_event:1983, identity=0x10004, stream-on done
I/mm-camera(199): isp_streamon: E, session_id = 1, stream_id = 4, stream_type = 5
I/mm-camera(199): wb_set_params: param_id is not supported in this module
I/mm-camera(199): wb_set_params: param_id is not supported in this module
I/mm-camera(199): wb_set_params: param_id is not supported in this module
D/mm-camera(199): module_faceproc_port_event_func:825] MCT_EVENT_MODULE_ISP_OUTPUT_DIM stream info 1920x1080 identity 10004 10003
I/mm-camera(199): isp_ch_util_streamon: session_id = 1, channel_id = 3, already active.
I/mm-camera(199): ispif_streamon: session_id = 1, active_streams = 3
I/mm-camera(199): mct_pipeline_process_set: Stream on/off returned
D/mm-camera-intf(186): mm_stream_qbuf: Starting poll on stream 0xb7f4c4cc type :5
D/mm-camera-intf(186): mm_stream_qbuf: Started poll on stream 0xb7f4c4cc type :5
D/mm-camera-intf(186): mm_stream_qbuf: Starting poll on stream 0xb7f4bda4 type :1
D/mm-camera-intf(186): mm_stream_qbuf: Started poll on stream 0xb7f4bda4 type :1
D/mm-camera(199): module_faceproc_client_schedule_mode:1808] apply 3 report 2 new_mode 0
E/mm-camera-sensor(199): port_sensor_handle_upstream_module_event:1244 Reset previously set LED state!
I/AEC_PORT(199): aec_port_proc_downstream_event: Received LED state timeout. Reset LED state!
D/mm-camera(199): module_faceproc_client_schedule_mode:1808] apply 0 report 3 new_mode 0
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 1689470 CurPosition: 36
D/mm-camera(199): module_faceproc_client_schedule_mode:1808] apply 1 report 0 new_mode 0
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 634118 CurPosition: 33
D/dalvikvm(3354): GC_FOR_ALLOC freed 3373K, 35% free 17228K/26472K, paused 13ms, total 13ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 602020 CurPosition: 30
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 14ms, total 14ms
D/dalvikvm(3354): GC_FOR_ALLOC freed 3037K, 35% free 17227K/26472K, paused 14ms, total 14ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 552162 CurPosition: 27
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 15ms, total 15ms
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 8 exp 16
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 8 exp 16
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 8 exp 16
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 524040 CurPosition: 31
D/dalvikvm(3354): GC_FOR_ALLOC freed 3037K, 35% free 17227K/26472K, paused 13ms, total 14ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 17ms, total 17ms
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 9 exp 17
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 9 exp 17
E/mm-camera(199): cpp_module_process_frame_control:1458 failed: wrong queue for mct_type = 2 frame 9 exp 17
D/dalvikvm(3354): GC_FOR_ALLOC freed 3037K, 35% free 17227K/26472K, paused 12ms, total 12ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 328800 CurPosition: 33
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 21ms, total 21ms
D/dalvikvm(3354): GC_FOR_ALLOC freed 3037K, 35% free 17227K/26472K, paused 13ms, total 13ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 370341 CurPosition: 35
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 16ms, total 16ms
D/dalvikvm(3354): GC_FOR_ALLOC freed 3037K, 35% free 17227K/26472K, paused 14ms, total 14ms
I/dalvikvm-heap(3354): Grow heap (frag case) to 19.818MB for 3110416-byte allocation
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 398033 CurPosition: 37
D/dalvikvm(3354): GC_FOR_ALLOC freed 0K, 24% free 20265K/26472K, paused 16ms, total 16ms
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 397856 CurPosition: 39
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 424101 CurPosition: 41
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stoping poll on stream 0xb7f4bda4 type :1
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stopped poll on stream 0xb7f4bda4 type :1
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stoping poll on stream 0xb7f4c4cc type :5
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stopped poll on stream 0xb7f4c4cc type :5
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 440796 CurPosition: 43
I/mm-camera(199): af_util_cur_pos_after_lens_move: After move: FV: 438574 CurPosition: 41
I/mm-camera(199): af_util_update_focus_status: AF Status already updated to output!Return!
I/mm-camera(199): af_util_update_focus_status: AF Status already updated to output!Return!
E/mm-camera(199): mct_stream_metadata_bus_msg:Failed to get_buf
E/mm-camera(199): mct_stream_metadata_bus_msg:1259: NULL ptr
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stoping poll on stream 0xb7f4af54 type :8
D/mm-camera-intf(186): mm_stream_read_msm_frame: Stopped poll on stream 0xb7f4af54 type :8
E/mm-camera(199): mct_stream_metadata_bus_msg:Failed to get_buf
E/mm-camera(199): mct_stream_metadata_bus_msg:1259: NULL ptr
E/mm-camera(199): mct_stream_metadata_bus_msg:Failed to get_buf
E/mm-camera(199): mct_stream_metadata_bus_msg:1259: NULL ptr
E/mm-camera(199): mct_stream_metadata_bus_msg:Failed to get_buf
E/mm-camera(199): mct_stream_metadata_bus_msg:1259: NULL ptr
Any ideas?
The answer posted by my colleague at the following link solved our problem:
https://stackoverflow.com/a/27284543/914123
OK we had the same problem - Nexus 5 only, but with ZBar lib instead of ZXing.
The issue was resolved by switching from a SurfaceView to a TextureView - however this resulted in slower frame rates.
Through testing we found that our issue was caused by leaving the screen, bringing up the keyboard and going back - our solution was setting android:windowSoftInputMode to AdjustPan in the manifest.
Related
I can't find them documented anywhere. So what does the values in this Logcat error message mean:
06-28 14:59:53.172: E/dalvikvm(32679): 32679(...) stat: (e) 393 5941KB / (c) 0 0KB / (a) 27 69MB / (h) 730KB 2668KB 1937KB
I should additionally mention that after this message I got this:
06-28 14:59:53.172: D/dalvikvm(32679): GC_FOR_ALLOC freed 2050K, 65% free 4916K/13892K, paused 26ms, total 26ms
From Android Documentation :
D/dalvikvm: <GC_Reason> <Amount_freed>, <Heap_stats>,
<External_memory_stats>, <Pause_time>
Example :
D/dalvikvm( 9050): GC_CONCURRENT freed 2049K, 64% free 3571K/9991K,
external 4703K/5261K, paused 2ms+2ms
All fields name are self-explainatory, but some points to note :
freed 2049K - this is amount of live object freed by GC in this run
64% free 3571K/9991K - 64% of 9991K which = 6494K amount is free and 36% is live object size
I am making an app that involves a lot of animation.
For example:
I got a group of png files(50+) and iterate them with the frame rate of 15fps, to make it looks like an animation.
I have many groups of image files like that. image size: 480x800, with alpha.
my app works basically okay, while I found a lot of GC_FOR_ALLOC in the logcat while playing animation.
my question is that with so many GC_FOR_ALLOC, can I just ignore them, or figured someway to eliminate them? my app also has an minor problem, not sure if related with GC, on some older android devices, the frame rate can not get to even 10fps.
I tried to recycle the bitmap, but it seems only mark that item is available for GC.
I load image this way:
BitmapFactory.Options localOptions = new BitmapFactory.Options();
localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
try {
return BitmapFactory.decodeStream(context.getAssets().open(fileName), null, localOptions);
} catch (IOException e) {
e.printStackTrace();
}
return null;
after load the image, I draw them on SurfaceView, like this:
canvas.drawBitmap(BgImage,rectBG2, rectScreen2, null);
for every frame, I need to draw about 3 images(3 layers). not sure if that has anything to do with GC.
below is an example of those GCs:
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17653K/32583K, paused 29ms, total 29ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17653K/32583K, paused 25ms, total 25ms
E/ttt ( 4993): 64
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 25ms, total 25ms
E/ttt ( 4993): 64
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 37ms, total 37ms
E/ttt ( 4993): 83
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 37ms, total 38ms
E/ttt ( 4993): 68
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 25ms, total 26ms
E/ttt ( 4993): 53
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 25ms, total 26ms
E/ttt ( 4993): 62
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 67
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 67
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1501K, 46% free 17654K/32583K, paused 27ms, total 27ms
E/ttt ( 4993): 66
D/dalvikvm( 4993): GC_FOR_ALLOC freed 1500K, 46% free 17654K/32583K, paused 26ms, total 26ms
E/ttt ( 4993): 65
currently I am trying a way to load bitmap from JNI, like game engine did, not sure if this is the right way to do it.
While your app should run fine with those, I would say your best bet is to look into getting rid of them. Remember that this means your app is having to constantly free resources, which is time-consuming for your app (when it's running that much), and also bad from a memory management perspective. You can see a bit more about this here: https://stackoverflow.com/a/11312145/3342157 While you may not have any issues now, it could potentially cause major slowdowns later (if it isn't already).
As for how to get rid of them, remember that you should only have to reload the image if you are changing it. If you aren't, I would say to not reload it each frame. If you have several images it will swap between and can afford to use the memory (not sure on the image sizes), load them all at the beginning, and then hold on to them for rendering later. I see that you are specifically talking about animation, and my recommendation would be to create a sprite sheet to prevent having to load each individual PNG image.
I have got a problem which is driving me wild. I used Google Map API V2 in my Code and when I'm moving the map I can see the following Logcat output (on Nexus 7):
01-23 21:17:10.724: D/dalvikvm(5484): GC_FOR_ALLOC freed 4531K, 21% free 12911K/16312K, paused 29ms, total 29ms
01-23 21:17:10.724: I/dalvikvm-heap(5484): Grow heap (frag case) to 13.043MB for 285724-byte allocation
01-23 21:17:10.744: D/dalvikvm(5484): GC_FOR_ALLOC freed 200K, 22% free 12990K/16592K, paused 25ms, total 25ms
01-23 21:17:12.074: D/dalvikvm(5484): GC_FOR_ALLOC freed 1326K, 23% free 12893K/16592K, paused 30ms, total 31ms
01-23 21:18:04.854: D/dalvikvm(5484): Debugger has detached; object registry had 1 entries
01-23 21:18:07.374: D/dalvikvm(5484): GC_FOR_ALLOC freed 658K, 23% free 12904K/16592K, paused 27ms, total 27ms
01-23 21:18:07.384: I/dalvikvm-heap(5484): Grow heap (frag case) to 13.763MB for 1048592-byte allocation
01-23 21:18:07.404: D/dalvikvm(5484): GC_FOR_ALLOC freed 2K, 21% free 13925K/17620K, paused 27ms, total 27ms
01-23 21:18:07.714: D/dalvikvm(5484): GC_FOR_ALLOC freed 2127K, 26% free 13054K/17620K, paused 29ms, total 29ms
01-23 21:18:44.694: D/dalvikvm(5484): GC_CONCURRENT freed 1894K, 27% free 12970K/17620K, paused 4ms+5ms, total 56ms
01-23 21:18:46.684: D/dalvikvm(5484): GC_CONCURRENT freed 1738K, 27% free 12996K/17620K, paused 4ms+2ms, total 53ms
01-23 21:18:49.254: D/dalvikvm(5484): GC_CONCURRENT freed 1756K, 27% free 13014K/17620K, paused 2ms+8ms, total 77ms
01-23 21:18:56.864: I/dalvikvm(5484): Jit: resizing JitTable from 8192 to 16384
01-23 21:18:56.934: D/dalvikvm(5484): GC_CONCURRENT freed 1840K, 21% free 13010K/16312K, paused 2ms+4ms, total 49ms
01-23 21:18:59.434: D/dalvikvm(5484): GC_CONCURRENT freed 1779K, 21% free 12995K/16312K, paused 4ms+5ms, total 50ms
01-23 21:19:03.414: D/dalvikvm(5484): GC_CONCURRENT freed 1781K, 21% free 13007K/16312K, paused 2ms+3ms, total 48ms
The heap keeps growing and growing and I have no idea what I can do about it. I searched through the web and through stackoverflow, but there was no helpful answer for me.
I hope someone of you can find the error. I am very new to Android, so please appreciate.
EDIT1: Heap Dump:
EDIT2: MAT Analysis
Suspect 1:
One instance of "maps.by.a" loaded by "dalvik.system.PathClassLoader # 0x4480cfa8" occupies 1.002.352 (22,33%) bytes. The memory is accumulated in one instance of "maps.by.d" loaded by "dalvik.system.PathClassLoader # 0x4480cfa8".
Keywords
maps.by.a
dalvik.system.PathClassLoader # 0x4480cfa8
maps.by.d
Suspect 2:
3.507 instances of "java.lang.Class", loaded by "<system class loader>" occupy 795.104 (17,72%) bytes.
Biggest instances:
•class com.ibm.icu4jni.util.Resources$DefaultTimeZones # 0x401fccc8 - 151.744 (3,38%) bytes.
•class android.text.Html$HtmlParser # 0x4016d288 - 126.592 (2,82%) bytes.
•class org.apache.harmony.security.fortress.Services # 0x40091188 - 51.456 (1,15%) bytes.
Keywords
java.lang.Class
Suspect 3:
8.168 instances of "java.lang.String", loaded by "<system class loader>" occupy 529.048 (11,79%) bytes.
Keywords
java.lang.String
First, your heap doesn't "keep growing". It is hovering between 12893K and 13054K, rising and falling, with one outlier peak at 13925K. Personally, I don't see anything in that log that would worry me.
Regarding your MAT output, if those are the three top culprits, none are surprising. The latter two say "I am writing an app for Android", as those are always there on any Android app. The first one indicates that Maps V2 has one rather pudgy object. Again, I see nothing in that output that would suggest a problem.
I am trying to setup a android virtual device to test syncing with an activesync-server.
I followed these steps:
The problem is that syncing is not working at all, but there are no errors like connection errors ...
IMO the problem is that the virtual device only has a private IP, so the server never can send anything to it?
So I probably need some kind of forwarding, like here:
But I am not sure if that’s correct and I am also not sure which ports should be forwarded.
Here is the logcat, when I want to sync:
W/InputMethodManagerService( 148): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41302038 attribute=null
I/Choreographer( 274): Skipped 41 frames! The application may be doing too much work on its main thread.
D/dalvikvm( 477): GC_CONCURRENT freed 396K, 6% free 8392K/8903K, paused 15ms+7ms, total 527ms
D/dalvikvm( 274): GC_CONCURRENT freed 360K, 11% free 9493K/10567K, paused 29ms+48ms, total 142ms
I/EAS ContactsSyncAdapterService( 477): Contact sync requested for test#example.com
D/dalvikvm( 148): GREF has increased to 601
D/dalvikvm( 477): WAIT_FOR_CONCURRENT_GC blocked 0ms
I/Choreographer( 274): Skipped 33 frames! The application may be doing too much work on its main thread.
D/dalvikvm( 477): GC_EXPLICIT freed 333K, 7% free 8355K/8903K, paused 78ms+32ms, total 1269ms
I/EAS EmailSyncAdapterService( 477): performSync
I/EAS EmailSyncAdapterService( 477): Mail sync requested for test#example.com
D/dalvikvm( 460): WAIT_FOR_CONCURRENT_GC blocked 0ms
D/dalvikvm( 460): GC_EXPLICIT freed 216K, 5% free 8483K/8839K, paused 145ms+94ms, total 914ms
D/dalvikvm( 148): WAIT_FOR_CONCURRENT_GC blocked 0ms
D/dalvikvm( 148): GC_EXPLICIT freed 510K, 7% free 11338K/12167K, paused 8ms+35ms, total 323ms
D/dalvikvm( 274): GC_CONCURRENT freed 415K, 11% free 9486K/10567K, paused 25ms+28ms, total 125ms
E/Inbox[test#example.com]( 477): Uncaught exception in EasSyncServicejava.lang.ArrayIndexOutOfBoundsException: length=32; index=32
E/Inbox[test#example.com]( 477): Sync ended due to an exception.
D/dalvikvm( 477): GC_CONCURRENT freed 376K, 6% free 8420K/8903K, paused 5ms+18ms, total 66ms
I don't think this is a problem with your networking setup. It looks like you have an error in your Sync code, that is causing the process to stop:
E/Inboxtest#example.com: Uncaught exception in EasSyncServicejava.lang.ArrayIndexOutOfBoundsException: length=32; index=32
E/Inboxtest#example.com: Sync ended due to an exception.
>
Wrap this code in a try/catch block to understand what is happening better.
Dont know if anyone has come across this issue but I am creating an app for mobile devices and it runs fine on my galaxy s2 running ics 4.0.4 however when I run it on the galaxy tab running 2.3.3 it keeps throwing errors.
All that I am doing is getting the device camera and attaching it to a flash.media.Video. I have the suspicion that the amount of errors caused by this issues is severly affecting the perfomance.
I have attached an fxp file ( https://www.box.com/s/77a9460edcf8a7ce95ee ) so that you can see that I am not doing anything out of the ordinary.
THanks for your help!
P.S.
Here is a sample segment of the logcat-
D/TvOut-Engine( 79): (isHdmiCableConnected): mHdmiCableConnected 0
D/CameraHardwareSec( 75): MemoryHeapBase(fd(26), size(5760128), width(800), height(600))
W/AudioFlinger( 75): RecordThread: buffer overflow
D/dalvikvm(12597): GC_FOR_MALLOC freed 1206K, 48% free 4217K/8007K, external 4034K/4493K, paused 91ms
V/AudioHardwareALSA( 75): resampler read error -32
D/AudioHardwareALSA( 75): AudioStreamInALSA::read error -32
D/AudioHardwareALSA( 75): AudioStreamInALSA::snd_pcm_recover error 0
E/v4l2_utils( 75): Error = Invalid argument from qbuf
E/CameraHardwareSec( 75): ERR(int android::CameraHardwareSec::previewThread()):overlay queueBuffer fail
I/dalvikvm-heap(12597): Grow heap (frag case) to 16.060MB for 5760016-byte allocation
D/dalvikvm(12597): GC_FOR_MALLOC freed 203K, 30% free 9638K/13639K, external 3975K/4493K, paused 26ms
E/v4l2_utils( 75): Error = Invalid argument from qbuf
E/CameraHardwareSec( 75): ERR(int android::CameraHardwareSec::previewThread()):overlay queueBuffer fail
D/dalvikvm(12597): GC_CONCURRENT freed 91K, 31% free 9547K/13639K, external 3975K/4493K, paused 2ms+13ms
D/dalvikvm(12597): GC_FOR_MALLOC freed 76K, 31% free 9471K/13639K, external 3975K/4493K, paused 43ms
E/v4l2_utils( 75): Error = Invalid argument from qbuf
E/CameraHardwareSec( 75): ERR(int android::CameraHardwareSec::previewThread()):overlay queueBuffer fail
I/dalvikvm-heap(12597): Grow heap (frag case) to 21.133MB for 5760016-byte allocation
E/v4l2_utils( 75): Error = Invalid argument from qbuf
E/CameraHardwareSec( 75): ERR(int android::CameraHardwareSec::previewThread()):overlay queueBuffer fail