windows store app crash due to timeout_expired - windows-runtime

I have a WINRT windows phone 8.1 app published on the store. The store dashboard shows a very mysterious crash event which occurs frequently. Its details are as follows.
Failure string name
EM_WATCHDOG_TIMEOUT_DEADA444_(MyAppName)_Timeout_expired:_event_type_=_SystemKeyPressed,_timeout_modifier_type_=_None,_server_task_currentState_=_Active,_targetState
I can understand that there is some sort of timeout expired in some calls. I can think of following places in app where that's likely
1) BackgroundUpload tasks - I am uploading files using background uploader
2) Web calls - App constantly makes web requests using HttpClient to a service
3) Suspension event - I am saving app persistence data while suspension
Has anyone faced similar crashes? Can anyone identify the exact cause for this?
(I know this question is quite vague but I can't provide more details)

Related

Access to Restricted data types and implement in development environment

We are developing application that needs write access to restricted data types. And looks like Google has stopped taking new request for whitelisting apps.
https://developers.google.com/fit/android/data-types#restricted_data_types
Note: Google has temporarily stopped taking new requests to write to restricted data types. We are updating our policy and process for reviewing requests and will update this documentation again when we resume.
Does anyone from Google have any idea when they will resume it?
Also: Is there a way to implement/write restricted data in development environment or debug build without whitelisting, and whitelist app before going to production?
There is no timeline yet for when this will be available.
(Source: I work on Google Fit)

Push message for Windows Phone (WNS): Blocked channel URL

I have a Windows Phone application running on a Windows Phone 8.1 device, and I am using Windows Push Notification Services (WNS) to deliver a push message to the device. Delivering push messages has worked for approximately 8 days, until I received WNS headers in the responses similar to these:
X-WNS-NOTIFICATIONSTATUS: dropped
X-WNS-STATUS: dropped
X-WNS-ERROR-DESCRIPTION: Blocked channel URL
X-WNS-MSG-ID: 2DC1361376C2827E
X-WNS-DEBUG-TRACE: DB5SCH101121937
I have not changed the push server implementation, nor the code on the Windows Phone device. There was literally no change in the build of either component. I went home at the end of a work day, and the next day, I ran a simple test only to be presented with that particular error. I have tried the following in an attempt to solve the problem:
Re-created the channel URL on the device.
Re-associated the existing Windows Phone application to the store.
Create a new Windows Phone application in Visual Studio (after association to the Store).
Re-created the Windows Phone application on the developer portal.
Used a different physical device.
Each without success. The documentation regarding WNS is sparse, there are no additional support channels that I am aware of, so I am stumped. What could be causing this particular error "Blocked channel URL", or, how do I solve it?
from your windows phone app you need to renew the url for the notification channel, because the url can be valid up to 15 days.
from the microsoft documentation:
"Request a channel each time the app launches. Channel URLs can expire and are not guaranteed to remain the same each time you request one. If the returned channel URL is different than the URL that you had been using, update your reference in your app server."
Edit:
see this link for reference https://msdn.microsoft.com/en-us/library/windows/apps/hh761462.aspx

Real-time error reporting from windows phone

Is there anything that can be done to get real-time error reporting from windows phone devices? I have code in my app that will catch errors to let users send them via email, but it's just not happening and yet I keep seeing errors being logged, very few but still occurs every few days, via the Dev center but without details, which is completely useless to me.
Any suggestions, tools, other would be appreciated.
Thanks.
If app crashes try get your info from UnhandledException event and write it to some kind of log file so next time app launches you can send those logs Reference
I've used it in WP8 application and worked fine. To get usefull information from exception do arg.ExceptionObject.ToString()
Use Application Insights to find out what users are doing with your app,
http://www.visualstudio.com/en-us/get-started/get-usage-data-vs.aspx

How do I structure my code to run a XAML page in a WinRT app and "return" a result?

I'm currently building a universal app for Windows 8.1 and Windows Phone 8.1.
In Windows Runtime, the file picker has a very easy to use API that looks like this:
StorageFile file = await openPicker.PickSingleFileAsync();
It treats user input as an asynchronous operation that can be awaited. In this instance, if a user cancels, null is returned, but you could imagine an exception being thrown if the user cancels.
I was wondering if there was some way to create a page so that I can create a similar API. Specifically, I am doing OAuth 2.0 authentication with a hosted service, and I want to send the user to the authentication page hosted in a WebView and return the code for requesting access tokens if the operation is successful or throw an exception if the user does not authorize my application.
For example:
var authentication = new AuthenticationAccess();
string code = await authentication.RequestAuthorizationAsync();
The call would swap out the Page in the Frame with the Page containing the WebView's, the user would be able to authenticate and then control would return back to the calling function and the page swapped back to the original page.
I'm kind of swimming in Windows 8.1 C#/XAML documentation. From what I understand, there is a global Window object that hosts a Frame object which can have its content swapped out with the different Pages in the application. Having done some Android development, I'm familiar with the Activity model, where essentially different pages can be initiated through intents and can propagate results back up to the Activity which launched it. With this model, it seems like it would be easy to wrap this process in the model I described, but I'm a little confused of how to do the same thing in Windows. Would I need to stand up significant architecture to achieve this pattern?
Is there a simple answer to this, or am I in over my head?
Have you checked out the WebAuthenticationBroker yet? Perhaps that could turn out to be an easy solution to your problem.
Otherwise - you can use TaskCompletionSource to set up the authentication task that you can await, but I'd try to avoid navigating to other pages for your authentication dialog since navigation events could mess up your states and break whomever is waiting for the authentication to complete. A dialog overlay of some sort might be a better idea.

Is there a way to persist cookies or HTML5 localStorage across WebBrowser instances on Windows Phone?

Short version: I have a WebBrowser control hosted in a Windows Phone 8 app. How can I store values from javascript so that they persist across the user closing and reopening my app?
Long version:
I'm developing a Windows Phone 8 application that has a single WebBrowser control hosted in a single MainPage.xaml page that lives for the entire life of my app. I created the app with the "Windows Phone HTML5 App" project type when creating the project in Visual Studio 2012. 99% of my application is hosted in web pages (on the internet, not stored on the phone) that I direct the WebBrowser to go to when the app starts up. In my application's web pages I'm trying to persist data across pages and across sessions. For example, once the user logs in once then I want to store that on the phone so the next time they start the app they don't have to log in again.
Cookies and HTML5 Local Storage (via window.localStorage.setItem and getItem) both work fine for sharing data across pages in the app while the app is running and even if you switch out of the app (via the Windows phone "hard button") and go back in. But if the user exits the app by pressing the hard "back" button then the next time the app is started all localStorage and cookies seem to be gone.
Is this the expected behavior? I guess I'm not sure where WebBrowser would store the data (Isolated Storage? Or maybe in the same place it's stored if going to the web site with Internet Explorer?). In any case, if there's no "fix" for this, can anyone the best way for me to provide my own storage mechanism so that I can let my javascript code persist values across instances of my app running? I'm happy to use the app's Isolated Storage if only I knew of a way to get and retrieve values from it using javascript. Thank you.
I'm not sure if this is expected behaviour or not.
To get at the Isolated Storage you will need to use JS/.NET interop.
if you want to trigger the persistent storage from JS:
Use window.external.notify in JS, generating a JSON string (for instance) to pass along to the .NET side. That could be written to IsolatedStorage without the .NET having to parse the data. You could use IsolatedStorage.AppSettings or a full file depending on the size of the data.
Alternately you could trigger the process from .NET:
Call WebBrowser.InvokeScript to call a JS function which returns the same JSON string representing your data.
The .NET side could detect and restore this data on startup and use WebBrowser.InvokeScript to pass the JSON string back into the WebBrowser via a JS function.
You'd of course have to deal with error cases (attempting to restore bad/corrupt JSON).
Also, if you trigger this from .NET in response to the App.Closing event you need to watch out that you don't take too long writing data.
The faster you run the better, but this definitely needs to be done within 10 seconds or the OS will kill your app.
See MSDN docs for WebBrowser.InvokeScript() and ScriptNotify registration to window.external.notify.