App restart after selected image from gallery

I’m using Samsung S3(android 4.3)
I need to load Base64 using getPicture from gallery

Here is part of my code

navigator.camera.getPicture(
		function(fileuri){
                    /* Read base64 from file_uri */
		},
		function(message){
			console.log('Failed because: ' + message);
		},{ 	
		quality: 50,
		destinationType: Camera.DestinationType.FILE_URI,
		sourceType : Camera.PictureSourceType.PHOTOLIBRARY
	});

Here’s read base64 function

window.resolveLocalFileSystemURL(fileuri,function(fileEntry){
    fileEntry.file(function(file){
        var reader = new FileReader();
	reader.onloadend = function(evt) {
		console.log("read success");
		console.log(evt.target.result);
	};
	reader.onerror = function(){
		console.log('load image error');
	};
	reader.onabort = function(){
		console.log('load image aborted');
	};
	reader.readAsDataURL(file);
    },logfail);
}, logfail);

I’ve tried getPicture using Camera it’s work well with no problem.

too hard to debug without more info

What we need to know is:
With what are you developing?
How your building your App (phonegap build/telerik platform, inhouse?..)
tell us everything you can!

Coze looking at your code i don’t see a problem.

But what i have readed is most likely you’re facing a out of memory problem:
http://community.phonegap.com/nitobi/topics/getting_image_from_camera_or_folder_restarts_app_android_samsung_galaxy_s_iii

I would try using the plugin form stackoverflow question.

I had something similar but on ios, the problem is within my IDE (Livesync from Appbuilder)
so i can not change it, have to wait for a fix:-D

This issue has been known for years…and they decided not to fix it. It really seems ridiculous that your app can be randomly garbage collected when you use plugins…Wow. I’ve quickly concluded that cordova is not a good platform. It’s clear from things like this…the basic camera is inoperable… Shouldn’t the ionic team take over here and fix some of these basic, critical issues? Who will use a platform that restarts the app? Now I have to use some foreground camera plugin that isn’t being developed on anymore and doesn’t work with ngcordova? What is this?
See for yourself how crazy this is.
https://issues.apache.org/jira/browse/CB-1513.

IONIC do us all a favor and fork all of cordova…fix it…and put it on github with your name on it. PLEASE. I can’t get my picture to orient correctly until i set a target height (even with correctOrientation= true) and it took be 30 minutes of research…no error…no warning…These plugins are awful. I might as well go back to native.

1 Like

recently after updating my android from 4.3 to 4.4 and rooting my device I am getting the same behaviour. When I select an image from gallery the application is restarted, but before on rooted android 4.3 it was working fine. Here is a short logcat, I assume the problem is in this part:

--------- beginning of /dev/log/main

D/MotionEngine( 2450): [MotionEngine] -> Add2MotionEventQueue(Not Define Motion ID : 111)

D/MotionEngine( 2450): [smart_scroll_event] MOTION_EVENT_SMART_SCROLL_CAMERA_OFF

--------- beginning of /dev/log/system

D/MotionRecognitionService( 2450):  .received : SMART_SCROLL_CAMERA_OFF

D/MotionRecognitionService( 2450): SERVICETYPE_MOTION Condition changed = CAMERA_MOTION

D/MotionEngine( 2450): [@@@ Motion Engine @@@] GetMotionScenarioId -0.239420 -0.028730 10.639832 0.000000 0.000000 0.000000 51 20

D/MotionEngine( 2450): [MotionEngine] -> PR_MOVE -> Move Recognition Lv(1)

D/MotionEngine( 2450): [@@@ Motion Engine @@@] GetMotionScenarioId -0.239420 -0.019154 10.716447 0.000000 0.000000 0.000000 51 20

D/MotionEngine( 2450): [@@@ Motion Engine @@@] GetMotionScenarioId -0.258574 0.028730 10.591949 0.000000 0.000000 0.000000 51 20

D/MotionEngine( 2450): [MotionEngine] -> PR_MOVE -> Move Recognition Lv(1)

D/MotionEngine( 2450): [@@@ Motion Engine @@@] GetMotionScenarioId -0.248997 0.019154 10.620679 0.000000 0.000000 0.000000 51 20

I/InputReader( 2450): Touch event's action is 0x0 (deviceType=0) [pCnt=1, s=0.460 ] when=8246264894000

I/InputDispatcher( 2450): Delivering touch to (3558): action: 0x0, toolType: 1

I/InputReader( 2450): Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=8246366894000

I/InputDispatcher( 2450): Delivering touch to (3558): action: 0x1, toolType: 1

I/AudioPolicyManagerBase( 1993): getSituationVolume: isBTConnected:0 isHeadConnected:0

V/AudioPolicyManagerBase( 1993): getParamFromPolicy  deviceInt = 0, situationInt = 1, situationVolume = 0.500000

V/AudioPolicyManagerBase( 1993): getOutput() device 2, stream 1, samplingRate 0, format 0, channelMask 3, flags 0

V/AudioPolicyManagerBase( 1993): getOutputsForDevice device 0002 -> 0002

V/AudioPolicyManagerBase( 1993): getOutput() returns output 2

V/AudioPolicyManagerBase( 1993): getOutput() device 2, stream 1, samplingRate 0, format 0, channelMask 3, flags 0

V/AudioPolicyManagerBase( 1993): getOutputsForDevice device 0002 -> 0002

V/AudioPolicyManagerBase( 1993): getOutput() returns output 2

V/AudioPolicyManagerBase( 1993): getOutput() device 2, stream 1, samplingRate 48000, format 1, channelMask 1, flags 4

V/AudioPolicyManagerBase( 1993): getOutputsForDevice device 0002 -> 0002

V/AudioPolicyManagerBase( 1993): getOutput() returns output 2

V/AudioFlinger( 1993): sharedBuffer: 0x44adf000, size: 15856

D/AudioFlinger( 1993): Creating track with bufferSize 15856 bytes, frameCount 7928, mFrameSize 2 

V/AudioFlinger( 1993): Track constructor name 4100, calling pid 3558

V/AudioFlinger( 1993): start(4100), calling pid 3558 session 112

V/AudioFlinger( 1993): ? => ACTIVE (4100) on thread 0x42e85868

V/LvOutput( 1993): initCheck: 0

V/LvOutput( 1993): attachEffects: attach processing to output 2, stream 1, session 112, mode 0

V/LvOutput( 1993): attachEffects: no output processing needs to be attached to this stream

V/LvOutput( 1993): LvOutput::setAllProcessorEnabled(false) mOutputs.size(0)

V/AudioPolicyManagerBase( 1993): startOutput() output 2, stream 1, session 112

V/AudioPolicyManagerBase( 1993): changeRefCount() stream 1, count 1

W/AudioPolicyManagerBase( 1993): stream type [13], return media strategy

W/AudioPolicyManagerBase( 1993): stream type [13], return media strategy

W/AudioPolicyManagerBase( 1993): stream type [13], return media strategy

W/AudioPolicyManagerBase( 1993): stream type [13], return media strategy

V/AudioPolicyManagerBase( 1993): getNewDevice() selected device 2

V/AudioPolicyManagerBase( 1993): setOutputDevice() output 2 device 0002 force 0 delayMs 0 

V/AudioPolicyManagerBase( 1993): setOutputDevice() prevDevice 0002

V/AudioPolicyManagerBase( 1993): setOutputDevice() setting same device 0002 or null device for output 2

V/AudioPolicyManagerBase( 1993): releaseOutput() 2

V/AudioFlinger( 1993): PlaybackThread::Track destructor

I/Gallery_Performance( 3558): Gallery onPause Start

E/AudioResampler( 1993): Unsupported sample format, 1 bits, 1 channels

D/AudioResampler( 1993): AudioResamplerOrder1::resample common!!!!!

D/AudioResampler( 1993): new common resampler(48000 -> 44100, 1, 1)

D/SoundAliveResampler( 1993): [SoundAliveResampler] Init+++

I/GlLayer ( 3558): pause = com.sec.samsung.gallery.glview.GlPhotoView@43eb8150, state = 1

D/AbstractViewBeam( 3558): unregister setting observer

I/GlLayer ( 3558): destroy = com.sec.samsung.gallery.glview.GlPhotoView@43eb8150, state = 2

D/GalleryStartAnimationChecker( 3558): setStop() : false

I/Gallery_Performance( 3558): Gallery onPause End

W/ActivityManager( 2450): mDVFSHelper.acquire()

D/PowerManagerService( 2450): setKeyboardVisibility: false

D/StatusBarManagerService( 2450): tr p:2450,o:f

D/PhoneStatusBar( 2681): setTransGradationMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false

I/SurfaceFlinger( 1990): id=222 createSurf (1x1),1 flag=404, leyreport

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

W/ContextImpl( 2450): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1513 com.android.internal.policy.impl.PhoneWindowManager.notifyToSSRM:6791 com.android.internal.policy.impl.PhoneWindowManager.access$300:201 com.android.internal.policy.impl.PhoneWindowManager$PolicyHandler.handleMessage:823 android.os.Handler.dispatchMessage:102 

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/SSRMv2:TSP:AirViewOnOff( 2450): SettingsAirViewInfo:: 000000000

D/PointerIcon( 2450): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0

D/PointerIcon( 2450): setMouseCustomIcon IconType is same.101

D/SSRMv2:TSP:AirViewOnOff( 2450): SettingsAirViewInfo:: 000000000

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/BarController.StatusBar( 2450): mState: WINDOW_STATE_SHOWING

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/StatusBarManagerService( 2450): tr p:23192,o:f

D/PhoneStatusBar( 2681): setTransGradationMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

I/GlRootView( 3558): surfaceDestroyed

I/GlRootView( 3558): finalizeView layer = com.sec.samsung.gallery.glview.GlPhotoView@43eb8150, content = null, GlAvala

I/GlLayer ( 3558): destroy = com.sec.samsung.gallery.glview.GlPhotoView@43eb8150, state = 0

D/STATUSBAR-StatusBarManagerService( 2450): manageDisableList what=0x0 pkg=WindowManager.LayoutParams

D/SystemWebViewEngine(23192): CordovaWebView is running on device made by: samsung

V/StatusBar(23192): StatusBar: initialization

D/PhoneStatusBar( 2681): Status bar WINDOW_STATE_SHOWING

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/CordovaInterfaceImpl(23192): Sending activity result to plugin

D/Activity(23192): #1 setTransGradationModeColor false

D/PhoneStatusBar( 2681): setSemiTransparentMode=false, mTransparentMode=false, mSemiTransparentMode=false, mMultiWindowMode=false

D/StatusBarManagerService( 2450): semi p:23192,o:f

D/CameraLauncher(23192): File locaton is: /storage/emulated/0/Img/20140107_171239.jpg

I/SurfaceFlinger( 1990): id=223 createSurf (1x1),1 flag=404, NainActivit

I/SpenGestureManager( 2450): setFocusWindow21005

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

D/PointerIcon( 2450): setMouseIconStyle1 pointerType: 1001iconType:101 flag:0

D/PointerIcon( 2450): setMouseCustomIcon IconType is same.101

W/AwContents(23192): nativeOnDraw failed; clearing to background color.

D/KeyguardUpdateMonitor( 2681): sendKeyguardVisibilityChanged(true)

D/KeyguardUpdateMonitor( 2681): handleKeyguardVisibilityChanged(1)

W/ContextImpl( 2450): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1513 com.android.server.InputMethodManagerService$4.run:2810 java.lang.Thread.run:841 <bottom of call stack> <bottom of call stack> 

I am stuck on this, please, someone help me to figure the problem out.

Any update on this? I’m getting the same behavior when using filepicker on android

Any update guys? Having the same problem and wondering why it has not been officially addressed.

Same problem here… Any update…??

The same problem here. The app restarts (only sometimes, randomely) after taking the photo by camera.

I am also getting Same problem… any update ??