Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Contributor
Kamil_Micazook
Posts: 9
Registered: ‎11-24-2011
My Device: BlackBerry 9360, Blackberry 9810, Blackberry 9100

Taking a photo crashes the application

Hello guys,

 

I am creating an application which the main functionality is taking photos. My problem is that after taking some photos I get 'Out of memory' alert and application crashes.

 

This situation happends on the 9860 device after taking 6-7 photos and on 9100 after taking few photos.

 

I am using latest SDK, memory card is inserted (and I am saving images on the memory card).

 

Does anyone have similar problem or know how to solve this problem??

 

Best Regards
Kamil

Retired
Tohman
Posts: 34
Registered: ‎10-24-2011
My Device: Curve

Re: Taking a photo crashes the application

It should be something to do with the way captured images are handled. Make sure you release resources that not longer in use, in addition you can reduce Image Size through camera options to the lowest size; it would significantly reduce image size.



1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the button below the post(s)
Contributor
tazbirs
Posts: 20
Registered: ‎11-22-2011
My Device: blackberry bold- 9700

Re: Taking a photo crashes the application

[ Edited ]

i am facing problem also while taking pictures. my app just hangs when i capture image. i don't understand what i did wrong..

my configuration

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets"
	 version="1.0.0.0">
  <name>helloWorld</name>
  <content src="index.html"/>
  <feature id="blackberry.media.camera" />
  <icon src="icon.png"/>
  <access subdomains="true" uri="file://pictures"/>
</widget>

 my js code:

 

/*******
works when "Take Video" button clicked
********/
function takeVideo() {
    var result = blackberry.media.camera.takeVideo(onVideoCaptured, onCameraClosed, onError);
}

/*******
works when "Take Photo" button clicked
********/
function takePicture() {
    var result = blackberry.media.camera.takePicture(onPhotoCaptured, onCameraClosed, onError);
}


/*******
post processing of photo click event
********/
function onPhotoCaptured(filePath) {
    var img = new Image();
    img.src="file://" + filePath
    img.width = Math.round(screen.width / 2);

    document.getElementById("photoDetails").appendChild(img);
}


/*******
post processing of video click event
********/
function onVideoCaptured(filePath) {
    var video = document.createElement('video');
    video.src="file://" + filePath
    video.controls = "controls";
    video.width = Math.round(screen.width / 2);

    document.getElementById("videoDetails").appendChild(video);
}

function onCameraClosed(closedEvent) {
    alert("onCameraClosed: " + closedEvent);
}

function onError(errorEvent) {
    alert("onError: " + errorEvent);
}

any help appreciated

thank you

Developer
jdnoprada
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: Taking a photo crashes the application

[ Edited ]

Hello Kamil_Micazook,

 

May I ask if you have any processes on the success callback of your takePicutre() method?

 

Hey tabzir,

 

I tried installing your application with a breeze. Everything went well, and the takePicture method returned with the proper filepath to the image. the only thing is that it did not display the image but otherwise, the application did not hang up.

Contributor
tazbirs
Posts: 20
Registered: ‎11-22-2011
My Device: blackberry bold- 9700

Re: Taking a photo crashes the application

yes. i tried it with 9930 simulator. it went well. my device is 9700. the image didn't show up because i didn't put any image tag in the div. :smileyhappy: thank you jdnoprada.
Developer
jdnoprada
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: Taking a photo crashes the application

Good to know that :smileyhappy: (though I don't think I've been of some help haha)
New Contributor
Kamil_Micazook
Posts: 9
Registered: ‎11-24-2011
My Device: BlackBerry 9360, Blackberry 9810, Blackberry 9100

Re: Taking a photo crashes the application

Hello jdnoprada,

 

Thanks for reply. Here is my javascript code:

 

function capturePhoto() 
{
	blackberry.media.camera.takePicture( photoSuccess, onCameraClose, photoError );
}

function photoSuccess( path ) 
{
	blackberry.media.camera.close();
	
	if( path != null )
	{
		path = 'file://' + path;
				
		var smallImage = document.getElementById('cameraImage');
		smallImage.src=path;
	}
}

function onCameraClose()
{
	console.log( 'camera close' );
}
	
function photoError(e) 
{
	console.log( 'photo error ' + e );
}

 

Best Regards
Kamil

Developer
jdnoprada
Posts: 68
Registered: ‎03-01-2011
My Device: Not Specified

Re: Taking a photo crashes the application

Hello Kamil_Micazook,

 

Well I don't see anything suspicious within your code. Could you check if your memory card has enough space? Or probably 

New Contributor
Kamil_Micazook
Posts: 9
Registered: ‎11-24-2011
My Device: BlackBerry 9360, Blackberry 9810, Blackberry 9100

Re: Taking a photo crashes the application

Hello jdnoprada,

 

Is there any way to set that (picture size, quality) programmatically? I know how to do that using PhoneGap, but how to set those options using pure WebWorks?

 

Thanks
Kamil

Developer
shnuffy
Posts: 268
Registered: ‎08-19-2009
My Device: Bold 9700

Re: Taking a photo crashes the application

[ Edited ]

Unfortunately the camera quality option is ignored by BlackBerry in PhoneGap apps too (note in the PhoneGap API the "BlackBerry Quirks" section says it "ignores the quality parameter"). 

 

It might be possible to do here in WebWorks, but would require somebody to write an extention to do so, which is not a trivial task.