WP8 AudioPlaybackAgent bug? - c#

I have a problem with playing audio tracks with the AudioPlaybackAgent on devices running WP8. It works perfectly on WP7, but not on WP8. It only works sometimes for WP8, so there is no clear steps on how to reproduce it either. What seems to be the problem is that when a new track is about to play and I have set the BackgroundAudioPlayer.Instance.Track to the new AudioTrack, it don't receive onPlaystateChanged.TrackReady.
Why is this? I don't receive onError either.
Is there a known bug with playing audio on WP8 devices? It happens about 50% of the time, and the same track can both work and not work. What can be the problem here? Please help. Any from Microsoft that can help on this? That would be highly appreciated.

The fact this occurs 50% of the time makes me suspect this could be a race condition which didn't occur on WP7.
Are you doing any thread-locking (using Mutex, lock() etc) from your background agent when changing tracks? I had something similar for a WP8 background audio app that was previously working on WP7 and traced it back to a deadlock in my code.
Don't forget that WP8 now has dual-core processors and is more likely to hit such issues. See this post from someone on the Windows Phone team about back-compat between WP8 and 7. Especially interesting is the section named "Runtime behavior changes" in that post.

Related

C#, BLE. Why does GetGattServicesAsync hang forever? Is there a work around such as turning off/on BLE?

I considered cross posting to the Super User site or similar but don't know how. As you will see this is not just a programming question.
I developed some C# code to communicate with an Onset InTemp thermometer via Bluetooth Low Energy (BLE). It works fine for a long time. I'm able to get beacons (which have the thermometer data) and also connect, get services and characteristics in case I need to get missed data or set parameters on the thermometer. However, after about 8 hours (can be as much as 24 hours) of continuously receiving beacons and connecting, getting historical data, etc., my app hangs on this line:
var gatt = await device.GetGattServicesAsync();
I put lines before and after this line and verified it's clearly hanging on this line. Again, it can be after 8 hours or 24 hours of use. It certainly chugs along just fine for quite a time. Killing and restarting the program is of no help. It hangs on the first call to:
device = await BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);
Only rebooting the PC fixes the problem. This is not surprising given the messages in the Windows Event Logs before it hangs:
The Bluetooth driver expected an HCI event with a certain size but did not receive it.
It's for this reason that I stated that this might be a SuperUser board question. No matter how badly I programmed my code :), killing the program should get BLE working again. FWIW, I did try disabling/re-enabling BLE through settings before rebooting.
I have found some links to this problem, but nothing very definitive.
I'm also working on writing a smaller, complete program to show the problem. So far, I can't get example program to fail from which I conclude that either (1) I haven't let it run long enough, or (2) I'm not fully duplicating what is going on with my full program. Perhaps I'm not putting as much pressure on the BLE drivers or I'm not listening for beacons and attempting to connect in the same ratios or with the same timing.
I should say that I see a lot of gripes about Windows implementation of the BLE Host layer and BLE drivers. Unfortunately, I'm stuck with Windows. Nordic also suggested that everything I'm reporting is a "known problem" and using their Nordic dongle will solve the problem. See for example: https://devzone.nordicsemi.com/f/nordic-q-a/65516/using-nrf52840-dongle-as-receiver-client-for-onset-thermometer.
That may well be true, but it would be a lot of work as they have libraries in C++ and Node.JS but not C#.
Any help is greatly appreciated.
Thank you!

Xamarin PCL Android app suddenly crashes in release mode

My Xamarin (PCL) Android application suddenly randomly crashes when it released. It sometimes happens even when you are not currently using it and then message that app stopped working appears.
I wonder, is there any way to track whats going on, maybe there are some logs which I could have a look, or anything else to find out what the issue as I said it randomly happens and hard to find the problem.
Many thanks in advance.
A fast solution would be to plug your device and use the Android Device Monitor to see if it print out something on the device logs. A more reliable solution would be of course to integrate a crash reporter system like what the others have suggested or Crashlytics.
You might need to add a crash reporting tool like HockeyApp or VS App Center, or wire up your own global exception handler

Xamarin iOS - SignalR stops receiving messages in background mode

Currently i am developing an app which needs to be capable of receiving and interacting based on realtime event notifications from all platforms. We are using SignalR to achieve so. I am using Xamarin.Forms as this is a shared project.
Right now everything is working fine especially android is perfect. No matter application is in background or foreground its receiving messages from SignalR and playing sound and vibrates as expected. In iOS 10.3 simulator also its working as expected. Untill yesterday when i realized in real device when application goes in background mode it pauses everything and when its back in foreground it resumes as its supposed to be doing and as if the notification was sent just now. So i did some research and thought i would perform a long running task (in my case a forever loop with a 10seconds interval) in the background thread and in that way i was able to receive signalr messages (which i can see on the debugger) and vibration was playing while being in background. But after a certain time i am guessing within 10 mins iOS is clearing up its memory and when i open the app it seems reloaded because it shows the login screen instead of where i left the app.
Now question is:
1. How can i keep receiving SignalR events while being in background?
2. How can i stop iOS to reload my app due to being in background for a long time?
3. The app has to be Appstore publishable as in appstore must not reject it due to some dodgy works being done in the background like playing silent audio forever or using VoIP for background since this is not a VoIP app.
4. Also soon i am gonna be implementing location update in background mode so is this gonna keep the whole app alive in background? And behave like i am expecting?
As i am currently travelling i can not provide any code snippet but any questions please feel free to ask.
Thanks for your help and reading this boring article.
Just in case if someone is facing similar issue.
Apple doesnt allow to execute your app unless it falls in certain category Look at table 3-1. Fortunately, I had a valid reason to use continuous location update in foreground and background therefore as soon as I implemented location update event all my problems were solved immediately.
How to implement location update? Location DependencyService example for Xamarin.Forms
Hope that will help.

Windows 7 Calculator breaks WPF Multi-touch?

I'm having a rather odd problem with a C# and WPF HMI I am working on currently. The HMI is a fairly complex program which allows the use to add and remove modules from a work area, dragging and resizing them to make the page they work on customizable. It works well, and after optimizations actually runs smoothly and works wonderfully with touch and animations. One gesture in particular is rather helpful, as you can (using multi-touch) place two fingers down on the screen and swipe left or right to change pages.
However, I have lately been getting complaints from our apps department that the touch will randomly stop working for any sort of complex movement, read as any sort of multi-touch. I spent a few hours tracking down what the problem was and it turned out, oddly enough to be linked to windows Calculator. Whenever calculator is opened, and subsequently closed, multi-touch ceases to function, and any breakpoints placed in the code show only a single touch being used. I took to the internet, and found a few articles corroborating the issue, but nothing even hinting at a fix other than don't allow calculator to work, which is sadly not an option as this HMI is meant for engineers who are manufacturing precision parts and they are a bit attached to calculator.
I stripped the problem down to its basics in which I made a simple c# and WPF touch app which kept track of how many touches it got, just to make sure its not just shoddy programming in the HMI. After getting the same results, no matter what I tried, I came here hoping someone else has run into and perhaps fixed this issue.
Here are some specs:
This HMI runs on Windows 7 and it is fully updated.
It is a C# program using Unity containers, Prism, and WPF
The touch is being handled through simple OnPreviewTouchDown and
TouchDown events
It doesn't matter if I run calculator through a Process in C# or if we run it from the actual OS, nor how we close the program, all permutations result in the same effect on every machine in the building with a touch screen.
It is an ELO touch screen with the newest drivers, though I have also tried it with a Vista Multitouch simulator and get the same results
Any sort of assistance or direction would be much appreciated. Thanks!
You are right. Microsoft released a fix recently for this issue for Windows 8 and other OS's, perhaps it applies to Windows 7 too.
Multi-touch gesture does not work after you exit the Calculator in Windows
Symptoms
This issue occurs in applications that are started before you
close the Windows Calculator (calc.exe) in Windows 8.1, Windows RT
8.1, or Windows Server 2012 R2.
Cause
This issue occurs because the Calculator exits and changes a
property. This causes the affected applications to stop responding to
multi-touch.
Resolution
We have released an update to resolve this issue.
See https://support.microsoft.com/en-us/kb/3024755
Workaround
To work around this issue, close and reopen the affected applications after the Calculator exits.

Windows Phone 8 app randomly crashes with error code -2147220717 (0x80040313)

I am currently developing a stopwatch and timer app in C#/XAML for Windows Phone 8. While using my app on my phone, I found that it randomly closed out/crashed and that too at different points of use (i.e. I wasn't doing the same thing each time it closed out). While debugging, I found that my app closed out with the following error code in my output window:
"The program '[1100] TaskHost.exe' has exited with code -2147220717 (0x80040313)."
I am very confused as to why this is happening. I tried creating an entirely new solution and moving my code over and I've still been getting the same issue. I have tried using the app on multiple different devices, and the same thing happens (even in the Emulator). Sometimes the app crashes after 5 minutes of use, sometimes it crashes after 30 minutes of use, it's very unpredictable which makes it very hard to find the root of the problem. My app uses the XNA Framework to play an audio sound and the Coding4Fun Toolkit for a TimeSpanPicker control, and besides that there isn't much else that's particularly notable about my app. I have tried removing the playing of the audio file and removing references to the XNA Framework, and the problem persists.
Any ideas on what the problem could be?
Thanks in advance!
That what David said +
are you sure that the phone is not running out of memory?
Edit try a windows phone analysis(Alt +F1 | Debug->Start windows phone application analysis)
If you're using XNA framework in WP project you can get a crash when updating the UI thread.
You might need to run it through a Dispatcher?
Dispatcher.BeginInvoke(() => {
// Call your update UI methods here..
});
You might also find this post helpful:
http://social.msdn.microsoft.com/Forums/wpapps/en-US/c2751845-cb70-4301-aa1a-796fa1bb8e8c/the-program-241435222-taskhostexe-managed-has-exited-with-code-0-0x0

Categories

Resources