Tuesday, January 24, 2012

WP7 Marketplace Certification Hell

A little Background
In late November / Early December I updated our application Camera Flashlight . The original version was turning on the camera flash (to be used as a flashlight) by causing the camera to continually auto-focus. The problem with this method is that it caused the flash to blink on an off momentarily once the camera had focused.  Not ideal for a flashlight but it's an approach that almost all wp7 flashlight apps seem to use.

Since then I worked out how to keep the flash on via accessing the video recorder which is much more desirable because it results in a constant stream of light without blinking.  It also puts less stress on the phone's camera.


Certification Hell
In early December I submitted this application and 5 days later got a message saying that it had been rejected because the application terminated silently on startup.  I had recently started obfuscating my applications with Eazefuscator and thought that maybe that was the cause.  So I switched to another obfuscation program and resubmitted.  6 days later I got the same message. 

By this time I was at a bit of a loss as to the cause. I always try to build good exception handling into my apps so silent termination should not really possible.  The user should always get redirected to a custom error page.  I had also sent the xap to my business partner Jeremy and he was able to side load and run it on his phone without issue. I'd checked the forums but didn't find anything of much help.  So I decided to send a support ticket asking for more information and also asking if the obfuscation could be the cause. 
The response I got was almost comical.

Hello Jeremy,

Thank you for contacting the Windows Phone App hub Developer Support Team. My name is Gary and I will be assisting you. For questions of a more technical nature, the best resource for information would be the App Hub Community Forums. There you will be able to get responses from not only other developers that have may have similar experiences, but also from internal Microsoft Windows Phone team members, as they respond to developer issues there on a regular basis. I have provided the link, below, for your convenience.

http://forums.create.msdn.com/forums/98.aspx


Thanks,
Gary
Windows Phone App Hub Developer Support 

So for a yearly registration fee of $99 all I get is a generic email saying if you have a technical query check the forums. Thanks alot Gary! After that I tried another 3 times to submit my application with small capability changes to wpmanifest.xml file as well as trying g to submit with no obfuscation.  Everytime I was rejected for the same reason.  By then almost 2 months had passed and I didn't seem any closer to having my update on the marketplace. 

The solution
In fairness to Gary at Microsoft Support I did eventually get a few ideas from the forums which pushed me in the right direction.  The first was that you can do beta testing.  This was one of those marketplace features that I was aware of but had never used and kind of forgot about. I submitted my application to beta test.  24 hours later I was able to download it onto my handset via the marketplace.  Sure enough the application terminated silently on startup.  Finally I was able to repeat the issue.

Next I found a forum post indicating that the capabilities in the manifest file could be the cause of my problem.  Well I had already looked at capabilities and run the capability detection tool.  No issues were obvious there.  However the post got me thinking that I might have misunderstood a few things.  I did a bit of research and it turns out that I had totally got it wrong.  I thought that the capabilities you defined in your wpappmanifest file defined what the apps capabilities would be in the marketplace.  I assumed the detection tool was for detecting what capabilities were requried and making sure you had them in your wpappmanifest file and that you hadn't included any unneccesary ones.  However it turns out that when you upload your app to the marketplace it compeltely overwrites your wpappmanifest.xml file with one based on the capabilities that the marketplace detects. 

It seems that a limitation in the detection process was meaning the camera and audio capabilities were not being detected and so the following required lines were being removed from wpappmanifest.xml file.


<Capability Name="ID_CAP_MICROPHONE" />
 <Capability Name="ID_CAP_ISV_CAMERA" />

*Note. you need the microphone capability when accessing the video camera

So these missing capabilities were the problem.  My next issue was how to trick the market place into detecting them.  By adding the following dummy lines of code to my project I was able to achieve this as was confirmedby the capability detection tool

MainPage.xaml.cs
private VideoBrush videoRecorderBrush;
private CaptureSource captureSource;
private VideoCaptureDevice videoCaptureDevice;

App.xaml.cs
Microsoft.Xna.Framework.Audio.Microphone mic = null;

I submitted the application for a beta test. Downloaded it from the marketplace 24 hours later and it was now running correctly.  Problem solved.

Summary
I felt kind of stupid that I had spent so long on such a small and seemingly obvious problem.  But then I got thinking my misunderstanding of how capabilities worked was fairly reasonable.  I really don't see the point of capabilities being based on those in the wpappmanifest.xml file during development if they are just going to get overwritten on marketplace upload.  To me it would make alot more sense if capabilities detected by the capability detection tool be automatically used by visual studio when developing an application. Of course it might be nice to override this behaviour.  But by default it makes a lot more sense. 

Anyway v1.1 of Camera Flashlight has now been approved by the wp7 marketplace and should be available sometime in the next 24 hours.   I hope this post helps someone as I was pulling my hair out for a while there.

1 comment:

  1. Really helpful post. It was good to know that the appmenifest got rewritten based on detected capabilities. Thanks for the detailed explanation.

    I had a similar problem with one of my submission. In my earlier app the images with frame rate counters got approved and are currently available on the marketplace at http://www.windowsphone.com/en-SG/apps/16631e30-b13a-4699-9e02-9d08a965ecbc. But similar images for a different app got rejected because of frame rate displayed on them. I guess it depends on the person as well who does the testing and verification.

    ReplyDelete