s3eCameraCaptureToFile fails every time

Home / Forums / Marmalade Archive / Marmalade System / s3eCameraCaptureToFile fails every time
12 replies [Last post]
by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750

When I call s3eCameraCaptureToFile(), it opens the camera app and I can take a photo and save it, but it still returns failure every time on my Samsung Galaxy S2 with Android 4.0.3, giving the error S3E_CAMERACAPTURE_ERR_CANCELLED, even though I chose to save the image. I'm using Marmalade 6.0.3.

I have tried with several different camera apps and they all fail.

Do others not have this problem?

I'm using S3E_CAMERACAPTURE_FORMAT_JPG, which should presumably be supported on all platforms. Interestingly when I call s3eCameraCaptureIsFormatSupported(S3E_CAMERACAPTURE_FORMAT_JPG) it returns neither S3E_TRUE nor S3E_FALSE as the docs say it should, instead returning 255, which appears to be S3E_WEOF. What's that about?

I tried PNG instead. s3eCameraCaptureIsFormatSupported() says it's supported, but in this case s3eCameraCaptureToFile() doesn't even open the camera app.

I tried the sample camera capture app, and it does indeed work, but I can't see any difference. It's just one function call so what can go wrong? My code is basically identical to the sample:

	s3eResult result;
	static char path[256];
	memset(path, 0, 256);
	result = s3eCameraCaptureToFile(path, 256, S3E_CAMERACAPTURE_FORMAT_JPG);

Any ideas?
Thanks,
Rob.

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
Having seen an old thread

Having seen an old thread about s3eCameraCaptureToFile() not working when MemSize was too big, I copied all my app.icf settings across to the camera capture sample app, but still that app works while mine does not.

What else could be causing it to return S3E_CAMERACAPTURE_ERR_CANCELLED??

Thanks,
Rob.

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
(As an aside, why does it

(As an aside, why does it keep telling me that my "evaluation" license has expired whenever I post here? I have a full license. I believe it is coming up for renewal within the next few weeks, but it has not expired yet.)

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
And just to confirm, I am

And just to confirm, I am calling this directly from my Marmalade UpdateApp() routine, not in a separate thread or anything. Still fails every time.

(Re licensing, I have a long-expired evaluation license, and an active standard license. It seems to always complain about the expired eval. I tried releasing the old eval, but it still comes up with the error. Is there a way I can delete it from the list?)

by: Lior
Status: Offline
Joined: 2012-04-02
Points: 670
I'm also having severe issues

I'm also having severe issues with s3eCameraCaptureToFile.

see here:

https://www.madewithmarmalade.com/devnet/forum/black-screen-ios-after-calling-s3ecameracapturetofile-heap-size-greater-10mb-3#co...

We are concerned, as this is the center of our app. Please let us know how can we fix ASAP

thanks
Lior

by: Lior
Status: Offline
Joined: 2012-04-02
Points: 670
Hi

Hi

So I found this guy: http://www.madewithmarmalade.com/devnet/forum/iphone-4-camera-problem-3
and seems he also have issues. so I have to conclude that the camera in Marmalade is VERY buggy and problematic. I thought to write my thoughts here in the hope that someone can brainstorm with us and lead us to the right direction.

The symptom for my device (Galaxy ||) is a that the app restarts after returning from s3eCameraCaptureToFile
logging a debug message to a file, right after returning from the call, doesnt happen. So the restart happens before this code.

I would think this is probably some corruption of variable or memory. the PC (program counter) or the stack area gets corrupted, causing the application to start executing from a different place.

which leads me to pose the following options on why it happens:

FIRST is memory. it seems that if the application uses less memory, there are less chances of the crash after s3eCameraCaptureToFile. but i would put less likelihood on this option, since even if the the native camera used requires more memory, this memory should not corrupt the memory already used by the app - unless there's a stray pointer in the native camera, which I doubt, as it works well with other apps.

SECOND is loose pointer and multi-threading. perhaps there's a thread running in the native camera that is accessing a variable that is also used by the app. but I would believe that the native camera, probably accessed through SDK, cannot access any variables on the app side. maybe it is the wrapper s3eCameraCaptureToFile which is buggy.

THIRD is opengl issues. maybe the native camera takes ownership of the opengl, changing some values and hence making it difficult, if not impossible, for the Marmalade app to regain control after returning home from the call.

THIS all means that we have a few options to fix it:
(a) re-write camera access using the EDK
(b) deal with the graphics issues by shutting down graphics before calling the s3eCameraCaptureToFile or (c) use only native UI

Can anyone from Marmalade share some knowledge? deny it? offer more options? Fix it maybe?? this is a HUGE deal for many of us who have come thus far and suddenly facing issues.

many thanks
Lior

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
Hey Lior, have you tried

Hey Lior, have you tried Marmalade's sample camera capture app? For me the sample app works fine, but the same call in my app fails every time. It doesn't crash, but it's still useless.

You'd think taking a photo would be one of the simplest things to do in an app!

Oh, is your Galaxy S2 on Android 2.3 or 4.0? I'm on 4.0.

Thanks,
Rob.

by: Lior
Status: Offline
Joined: 2012-04-02
Points: 670
Hi

Hi

the sample app works for me, all while my app did crash. But, i've now restarted the phone and its working again.
However, this is not a real solution. First, from my experience,the crash will happen again Second, users wont bother restarting the phone after they download your app; they'll just delete it.

I think we have two more hopes.

One, is that someone from the Marmalade team will help (Hello anyone?)

Second, we could try is to develop an extension using Java, and see if it will help. Do you know of Java code we can try with? yet i'm concerned that the problem lies deeper

thanks
Lior

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
I figured until I could get

I figured until I could get the camera capture stuff working, I'd just add an image browser instead, but guess what, that doesn't work either! Calling s3eImagePickerToFilePath(S3E_IMAGEPICKER_FORMAT_ANY, 1) always returns 0 for me. It opens a gallery and allows me to select an image, but again, it returns 0 as if the operation was cancelled. That's on Android (Galaxy S2 with Android 4.0.3). In the emulator however it does indeed work.

We use java for a couple of things. I tried removing all use of java to see if that helped, but it made no difference. I don't fancy having to write camera and gallery EDKs ourselves! This is really Marmalade's responsibility.

I will try removing more stuff until I get back as close to the sample app as I can, and see if I can figure out which bit makes the difference.

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
I think I've found the

I think I've found the problem! Although now I'm stuck at another problem a few steps farther along.

I stripped out all our code and ended up with our code and the sample app being EXACTLY the same! But still the sample app worked and ours didn't. This led me to look at AndroidManifest.xml. I eventually (after most of the day) tracked it down to the launchMode setting, which we had as singleInstance, but the sample app had as singleTask. I changed ours to singleTask and now the camera and image picker finally work!

Lior, does this solve the problem for you too? For me mostly the functions just returned failure, but I did find one or two images that would crash when I tried to select them with the image picker, which sounds more like the problem you had.

Now I'm at another road block because I want to display the captured image in a dialog box using CIwUIImage, and it seems to struggle to survive with 8MP images from the camera. Small images work, but it crashes every time on full size images. Or at least it did until I put diagnosics in there, after which it displayed the image and crashed when trying to close the dialog. How do crashes always know to happen where there's no diagnostics?!

by: Lior
Status: Offline
Joined: 2012-04-02
Points: 670
Hi Rob - thanks very much...

Hi Rob - thanks very much... but our xml is already singleTask. (what is the difference, btw?) our problem is a bit different, the app is occasionally restarting upon return from the gallery/camera

thanks again
Lior

by: RobW
Status: Offline
Joined: 2011-03-30
Points: 3750
The only other thing I can

The only other thing I can think of is to make sure you've got the right permissions in your manifest file, including:

  <!-- Required by s3eCamera. -->
  <uses-permission android:name="android.permission.CAMERA"/>
  <uses-feature android:name="android.hardware.camera"/>
  <!-- <uses-feature android:name="android.hardware.camera.autofocus"/> -->
  <uses-feature android:name="android.hardware.camera" android:required="false"/>

Marmalade really don't document the need for various permissions very well. It's not mentioned anywhere that I could find in the docs for camera capture (for example, is the autofocus permission above required? Seems not, but we're not told). But I guess you already have those, and I think the gallery should work without them anyway.

Sorry, I was sure singleTask would work for you too! I don't know how ours got to be singleInstance. Hopefully there wasn't a good reason! I don't really understand the difference.

by: Lior
Status: Offline
Joined: 2012-04-02
Points: 670
Thanks Rob. i've done some

Thanks Rob. i've done some reading and actually singleTask is exactly what you need, as it allows the app to use other tasks (and that other task is the camera). SingleInstance does not allow

I'm very concerned about the issue we are experiencing because the restart-after-camera is intermittent. that's the hardest to figure out. The silence from the Marmalade team doesn't help either

I'll check the permissions you've outlined. that could lead somewhere

many thanks again
Lior

Latest Posts

Latest Comments

Top Contributors

  • Chris D : 27,010
  • MonRoyals : 26,970
  • Salman : 26,720
  • Jez Hammond : 20,130
  • pjan : 11,150
  • gjw : 10,350
  • Paolo Oliverio : 9,640
  • Beaker_2 : 8,390
  • Kite : 8,210
  • bluescrn : 7,810