Please note that as of October 24, 2014, we will be archiving some of the Nokia Developer discussion boards. The Nokia Asha and Nokia X sections will remain open for continued use. The "Windows Phone/Lumia" and "Other Platforms" sections will become read-only. For your Windows Phone development questions, we invite you to visit the Microsoft Developer Network (MSDN) discussion forums.

If this is your first visit, be sure to check out the FAQ. To start viewing messages, select the forum that you want to visit from the selection below.

PhotoCamera.CaptureImage() fails with front facing camera on Lumia820

Hello everybody.

I am pretty new to the WP platform, and am currently researching some of the APIs I will need for my next application.

Using the article called "How to create a base camera app for Windows Phone" as a starting point, I wrote a very simple application that is supposed to capture a single picture using the front facing camera, which works as expected on the emulator, but fails when I run it on a physical device. However, it runs fine on the device if I use the back camera.

The problem I am experiencing is that after calling the CaptureImage() method on the PhotoCamera object, the CaptureStarted event fires as expected, but after that, the application hangs and no other event is fired (i.e. the capture never completes).

If I stop the application and start it again, I get a System.InvalidOperationException when calling the CaptureImage() method (with the following exception message: "You cannot use this instance until it is fully initialized"). At this point the only way to get the PhotoCamera object to initialize correctly is restarting the device.

The code is very simple, but I'm including it here so anyone can take a look at it (relevant portions only):

Am I doing something wrong, or missing something? (if so, why the App runs without issues on the emulator, or when using the back camera on the device?)

Is there something additional I can do to debug the issue? (I don't seem to find any additional way to debug the problem at a lower level)

Has someone else experimented this problem? If so, how did you solved it or worked around it?

Also, it would be really nice if someone else could try this operation on another 820 developer device. I'm starting to think that this is some kind of device-specific issue, maybe related to the firmware or something similar.

================================
UPDATE - 13/02/2013
================================
I modified the application to use the PhotoCaptureDevice class instead of PhotoCamera, as described in article "Advanced photo capture for Windows Phone 8", but the results are basically the same. After I call the capture sequence's StartCaptureAsync() method, the application hangs. As before, it only happens on the device when the front facing camera is being used.================================

================================
UPDATE - 14/02/2013
================================
I tried the same code on a Lumia 920 (through RDA) and it works without any issues, so this is probably not a flaw in the code, as I suspected. If anyone has the time, please test it on a 820 dev device.================================

I'm not sure if this is somehow related, but I tested the Microsoft's BLINK App a few days ago, and when I switch to the front facing camera in that App, my phone restarts. I asked a few friends about this on twitter , and one of them told me that she saw a similar behaviour on a 825 device.

I'm planning to start playing with the native camera APIs today, to see if it makes a difference. I've tested some camera apps and most of them work even when using the front camera, so even if this is a device-specific issue, there must be a way to make it work. The front facing camera is key for my next project, so I really need to be able to test it on my device. If the native APIs don't work, I will open a support ticket, and let you know the results.

Hello I've just tryed your code on a 820, and yes I get the same error as you, the app works first launch and when you take a pic it hangs, and it won't work after at all.
I uninstalled the app and tryed to deploy it on the device again but got an error as if the frontfacing camera is still used, then I tryed to open an app where the frontfacing camera works (Skype), got a black screen and the phone rebooted.

Hello I've just tryed your code on a 820, and yes I get the same error as you, the app works first launch and when you take a pic it hangs, and it won't work after at all.
I uninstalled the app and tryed to deploy it on the device again but got an error as if the frontfacing camera is still used, then I tryed to open an app where the frontfacing camera works (Skype), got a black screen and the phone rebooted.

Thanks for the feedback, Loukt, I really appreciate it.

Does somebody know if there is a place where we can report this to the appropriate Nokia engineers. I was planning to submit a support ticket, but if this is something that fails on every 820, maybe that is not the appropriate action to take.

There are differences in OS, firmware and transmision software versions. In all 3 cases your device appears to be running more recent versions. That could be the reason, but unfortunately nothing shows up when I check for updates on my phone.

I have not had the time to try the native camera APIs yet, but I hope to be able to do it next week (hopefully I can write a Wiki article on that topic when I finish testing).

The last WP8 Update solved the problem (Version : 8.0.10211.204).
We still don't know what causes it, but it's solved.

Yep, that's right.

I spent some days experimenting with the native APIs, but the official documentation on that topic is really bad, and the solution for my problem came (through the aforementioned update) before I could make those APIs work. Unfortunately my time is very scarce, so I will have to move away from the native APIs and continue working on my project using the managed ones.