iBeacon Monitoring While Device is Locked iOS 8.1 - ios8

I've been playing around with this for days now and the only conclusion I can come to is that CoreLocation is pretty buggy for this setup in iOS 8.1.
I had code that was correctly monitoring for a region (using UUID only, no major/minor) and the delegate methods didEnterRegion and didExitRegion were being called correctly, while the device was locked and the app had been terminated, which is what I want. These even worked after a reboot without issue.
I modified the code to pull some more UUIDs from a server and to start monitoring for those regions (only two more). They're working, but only while the device is awake and unlocked, the moment the screen is powered off then I get no hits on the delegate methods at all. The first UUID I used continued to work while these didn't, so I removed the app from the device to stop it from counting (I'm not calling stopMonitoring anywhere right now).... the two new regions still don't work when locked though.
Every version of iOS I've tried has exhibited different behaviour with beacons, and this is the most annoying one yet because when it was working it was being very responsive—powering up a beacon with the beacon with the first UUID would trigger delegate calls within a couple of seconds—but now it's just refusing to work.
Does anyone have any ideas around what's going on internally in CoreLocation and what I might be able to do to make this more reliable? Capabilities etc. are all present and correct as evidenced by the fact that it was working fine with the one region.

Related

Android Emulator on Mac unexpectedly sending terabytes of data per hour

I'm an iOS dev currently working on a android app (so very inexperienced with Android).
If I leave my android emulator instance open it sends huge amounts of data, 10's of GB's per minute slowing down my network. I just left it running for a couple of hours and it has send 11TB of data (yes that "T" is correct) (for context the next item in activity monitor has sent 300mb in the same period). (All according to Mac Activity Monitor anyway).
The activity monitor item is qemu-system-aarch64. I understand this to be emulator, as soon as I close emulator this data sending stops and if I force stop this process emulator quits.
I have deleted devices and created news ones running a variety of android versions and all seem to have the same issue.
I'm confident the data is not sent by my app.
Restarting Android Studio/Emulator/the Mac doesn't change anything
I can't see any large amounts of data being send via Proxyman or Little Snitch so I have no idea what's actually being sent or how to stop it.
My next move is to re-install Android Studio from scratch but would ideally like to know what's going on to prevent it in the future if this does solve it.
Does anyone have any experience with this problem or ideas as to what causes it? Any ideas on how to see what's being sent?
Any general nudges in the right direction would be greatly appreciated!
Thanks!

the garbage collector in Xamarin Ios it not working on devices

When I run xcode instruments and I profile on the emulator, my UiViewControllers Dispose methods are being called instantly after the view is removed. But when I run the app on the device, the dispose methods of all the UiViewController are never being called!. Or are called very slowly and the memory gets too high.
I don't know why this is happening. The problem is that the only way to get the app, in the device, to call the dipose methods is when I manually perform a Gc.Collect() in the AppDelagate ReceiveMemoryWarning and DidEnterBackground(). When any of those methods executes, the memory drops from 140MB+ to 70MB.
This is the image of the memory when app is running on the emulator.
Emulator Memory Allocation
And when I run the app on the device.
Device Memory Allocations
As you can see on the emulator the dispose methods are being called every time a UIviewcontroller is remove. But in the device, the dispose methods are never called. The drop that you see in the image of the device is when the app goes to beckground and I manually call a GC.Collect().
Why isn't doing it automatically in the ios device, like it does in the emulator?
I am very new to xamarin, I have spent 4 days trying to figure this out. I really don't know what to do.
I hope someone can help me.
When running Xamarin.iOS in debug mode on the simulator, there is a thread that continuously calls GC.Collect() every few seconds so the garbage collections happens way more often than on real device.
This is mostly to help you finding bugs in your code faster (like accessing a managed reference that is already gone). So this is the reason you are not seeing the collection happen as often as it happens on simulator when deploying to device.
You should not worry too much about collections not happening as often, GC heuristics will determine when it should happen, the times you do need to "worry" are when you are working with big managed objects like images etc. but creating those objects inside a using statement should be enough.

TangoService_updateTexture periodically returns old frames after resuming an app

When running the rgb_depth_sync example from the tango-c-samples, or any custom code for retrieving the raw textures via the tango OpenGL ES 2.0 TangoService_updateTexture interface, I encounter an error when resuming an already running app.
The texture periodically found in the buffer is the last frame from the previous run of the app until it was paused. It look as though the OpenGL texture buffer from the previous context is being stored and occassionally erroneously returned, however I have confirmed the glTextures in all of these examples are being deleted when the app is paused:
ColorImage::~ColorImage() { glDeleteTextures(1, &texture_id_); }
The application itself is also successfully disconnecting from the TangoService:
TangoService_disconnect();
Is anybody having similar issues? It appears to be a bug within the Tango API. The only (not really) workaround I have found is to completely restart the app. Has anyone found a solution to this within their applications, or are the Tango Team aware that this is a problem?
Just to note: I am already aware of the life-cycle known issue:
The current version of the Project Tango APIs are designed for a single app using Tango Service in the foreground. Multi-app usage is undefined so do not plan on users switching between multiple active Project Tango apps at this time.
However I was not sure whether resuming a single app to be run again in the foreground after pausing is encompassed within that issue, as the app itself is not
The fix to this particular problem is to update device BSP and the TangoCore from play store.

How do I debug a WP7 app that runs fine in debug, but crashes otherwise?

I have a problem with my Windows Phone app.
The app uses all the device sensors: gps, accelerometer and compass
When I run it in the emulator it's fine and when I debug it on the phone it's fine.
But when I remove the USB cable from the device and start the app again it crashes very soon and I dont know how to find out why because the debugger is not attached.
How can I debug such a problem?
There are a number of reasons that this can happen. It's hard to pinpoint precisely what's going on without some debug output, but here is a brief run down of the likely culprits:
Most Likely...
The most likely thing that's causing your app to crash in non-debug mode is poor start up time. I suspect you may be encountering what this S.O. question is all about. When the debugger is attached, the runtime bypasses the operating system's function of killing any app that takes longer than 10 seconds to load. This is an easy thing to test for, simply remove all the code that's being executed when the app starts up (I'm assuming you're hooking into GPS stuff at that moment, just comment that stuff out).
But Additionally...
While the above might solve your problem, you have to be wary of a few other issues you may also encounter:
When you access the GPS / Accelerometer / Compass you must check first to see if those sensors are actually accessible and provided by the phone. Not all windows phones are required to provide the compass. Take a look at the Hardware Specifications for Windows Phone. If you are trying to access the compass, and your device does not support the compass, then that could be your problem right there. More details on this here. The following code is an example of how you might check for the presence of the Compass on the device (note that the IsSupported will return true even if your device has the compass off).
using Microsoft.Device.Sensors;
public partial class MainPage : PhoneApplicationPage
{
Compass compass;
public MainPage()
{
if (Compass.IsSupported)
{
// awesome. you have a compass
}
else
{
// uh oh… you have a crappy phone, no compass for you :(
}
}
}
Have You Tried Turning It On And Off Again?
One of the other things you have to consider is that the device you are using has the GPS turned off (greater developers than you I am certain have made more foolish mistakes). If your GPS is turned off, or disabled, or the user (you, there, holding the device) has not authorized the app to use GPS data. See this article for dealing with the location considerations alone (a must-read if you're developing GPS enabled WP7 apps anyways).
Declare Your Intentions Sir
Lastly, there can be issues if you don't declare the things you're accessing from the device in the application manifest file. Basically, if you don't declare those as items your app uses, you can run into problems. The reason you need to declare what you're app uses is so that Microsoft can appropriately filter/warn/inform users who are downloading your app from the marketplace of the information your app requires to operate.
Battery Saver Mode
When a Windows Phone is in battery saver mode some of the sensors will be turned off to save battery life (things like... GPS, Compass, and Accelerometer). This could easily happen if your device isn't actually charging when it's plugged into your dev machine.
In Summary:
Check to see if your app is taking longer than 10 seconds to load
Make sure the device actually supports the sensors you are trying to access
Make sure that the data returned by the sensors is not causing your code to crash (for instance GPS may be on, but give a lat/long that is, according to your code errant, causing it to crash).
Make sure you declare usages in the application manifest file
Make sure your sensors are ON and you're not in battery saver mode
Hopefully one or all of the above helps you diagnose your problem. Lemme know if you find out that it's something else, would be curious to know what else could be causing this problem.
Have you considered adding MessageBox.Show method calls in any exception handling code you may have to display the particular exception message and even the stack trace? Also consider doing the same for the Application_UnhandledException event handler in the App.xaml.cs.
What you can do is to write all Debug-Informations like the Stacktrace and the Message into the IsolatedStorage which then you can display on a seperate Page.
The Problem may arise because the Phone uses the Internet of the PC if plugged in (Had the same Problem for quite a time)
It's worth using the Little Watson technique described by Andy Pennell in his blog here. This saves the exception details to Isolated Storage and will email it out from the app when the application next starts. There's full code in the blog.
The code is easy to adapt if you want to remove the emailing part and just want to manually pull the crash details from Isolated Storage from your development PC.

How to run arbitrary code when windows resumes from hibernate?

I need to run some code when my computer resumes from hibernate (even before I logon). The laptop I am using has a bizzare problem. If I have an external monitor connected to it while resuming from hibernate the laptop chooses the external display as the main video device and the laptop screen remains blank. This becomes more frustrating when sometimes both displays remain blank indefinitely.
I am thinking of writing some code to switch the active display back to the laptop screen when the computer resumes from hibernate. But which windows event do I need to look for to begin with?
The built in hot keys for switching the display have also stopped working. I have reinstalled the OS several times by now and things go smoothly for a few days after that and then its back to square one.
This article on CodeProject discusses the various Windows messages that relate to power saving events.
I think most laptops have issues with that. It is not something they seem to be able to solve in the drivers/ACPI BIOS.
I know Linux allows you to modify the ACPI tables, but I cannot remember if this is possible on Windows.
A Google should provide links to tools you can use to inspect your laptop's ACPI tables in Windows (MS tools IIRC).

Resources