Mobile Safari application cache bugs? - caching

I'm using Mobile Safari's cache manifest file to store a multi-page data entry application that is run on an iPod Touch (version 3.1.3) in offline mode. The application writes to the client-side database by way of the persistence.js ORM. This all works fine.
However, I run into the occasional, extremely hard to reproduce problem whereby Safari just seems to forget that the pages are cached. When this happens, the "Cannot Open Page" alert appears, which is the same one that comes up when you attempt to visit a non-cached website with the wi-fi turned off. The only way that I've found to fix this is to reconnect to a wireless signal and visit the site while online, which seems to set the cache straight. This is easy to do when you're in the office, but not so easy to do out in the field.
I'm not trying to reference anything outside of the cached resources, and I've verified that the application is cached by running through the entire site while disconnected, sometimes successfully for days on end. I feel like there's a bug in the OS that messes with the validity of the cache. I'm not necessarily looking for a solution to the problem (but that would be nice), but rather just some confirmation that others have encountered this problem.

Using a cache manifest and lot of troubleshooting, I am able to reliably cache an entire application; Do note that this is a single page app with only a few separate file resources.
As a further enhancement, I have been trying to modify the DOM based on
window.applicationCache status
to inform the user about updates, ie:
tap here to apply update
If that were possible, I could swap the cache
window.applicationCache.swapCache();
Which would allow me to swap in the updated cache and then restart the page to provide a streamlined update mechanism.
Potentially even more streamlined than apps from the apple store.
I suspect that the applicationCache API was hamstrung by Apple to hinder web apps for this very reason. Having said that, I believe the level of support for "html5" APIs on mobile devices is among the most robust in apple's safari.
Following are a few problems I have noticed so far, in no particular order. Please note that this is not a comprehensive list of bugs.
I never get an 'updateready' event; this alert line never runs:
window.applicationCache.addEventListener('updateready', function(e) {
alert('updateready event status=' + window.applicationCache.status );
}, false);
I can not manually check for updates. The following code gives me an exception
try{
window.applicationCache.update();
}catch (err){
alert('exception:\n' + err);
}
It seems that as soon as I start to interact with the cache state at all, the caching stops working. The bugs are fiendishly elusive; pinning down & isolating any one issue can take a lot of time, especially since all this code runs flawlessly on other browsers (chrome).
Now here's a good one:
I suspect that if you pin an app to your home screen, iCloud "backs up" resources and restores them after you run the app for the first time from the home screen. To avoid this issue, you may sometimes have to rename files. I have proven that apple makes discrete backups of obsolete components by
removing them entirely from my app server
deleting the pinned web apps from home screen
clearing all the caches
opening the app url in safari
verify that its the newest version
pin to home
verify that the pinned app the newest version
close it
run again - and its back to the old one, no longer on your server.
Finally, if you run the pinned app while the phone is in airplane mode, iCloud will not be able to restore the obsolete files. This proves that it's coming from over the air.

Related

Clear app data and cache on FORCE_INSTALLED apps when kioskCustomLauncherEnabled is on

We have a few private apps we distribute to dedicated Android devices, when we move them between users I want to be able to clear the app data from the apps. A few months ago, this was working but recently when we go to clear app data (from Settings) it isn't allowed by the policy.
We don't want users to be able to uninstall the apps but we do want to be able to clear app data so it doesn't retain user data from the prior user.
Is there a way to just clear a single apps data?
Is there some policy setting which controls whether or not you can clear app data?
Our current workaround is to manually switch to a profile without the apps (the ones we want to clear) then switch them back to the pertinent profile which forces and uninstall then reinstall of the apps. However, this is more cumbersome than we would like.
I think this is working as intended. +1 on kioskCustomerLauncher however being an app running in kiosk mode isn't a "secret", it's just transparent to the policy for ease-of-use, in my opinion :)
TheoL
AndroidEnterprise

View loading as blank/white screen in Mac desktop application Xamarin.Mac

I have a Mac desktop application developed using Xamarin.Mac and XCode. The application is loading views that should have a considerable amount of content as blank/white screens for a select few end users. While I've not been able to reproduce the issue locally and it doesn't appear to be impacting many people, it does happen consistently for a handful of users(6 out of over 4,000 at the moment). The app works just fine for the vast majority and uses a main window controller that sets the content view as needed by calling the applicable ViewController. When the views in question are loaded for the given users, it renders as a blank white area.
I did notice however that at least some of the objects in the views are actually there, just not visible. For instance, one view has buttons that are still "there" as you can click on them if you know where they are supposed to be positioned(and they also fire correctly) but they are not actually visible as the area is all white with no visible content. It's as if everything is loading properly but the UI just isn't cooperating in displaying objects that are actually there. The closest thing I could find was this Diagnosing run loop issue (partially frozen UI) in Cocoa application
However I'm not sure it's the same problem and there was no resolution for that either. Has anyone else ever encountered something like this?
Ok, got some new info. After doing a remote session with a user we had no luck with the hardware and the console didn't provide much insight, however we did stumble across a workaround that fixes the issue and may give some clues as to the real problem.
When the application is initially installed, we prompt the user to ask if they want it moved to the default Applications directory. They do not have to move it as it will work the same from pretty much anywhere but we do this for convenience. For the users having this problem, we noticed that they all had the app installed in the Applications folder. By sheer luck, one user accidentally chose to not move the app after reinstalling it per our support team. When the app was installed in his default Downloads directory, the problem vanished and the app worked as expected.
After testing various other directory locations(Downloads, Documents, etc.) we found that the issue only seemed to exist if the app was installed in the Applications directory. Furthermore, if the app was installed in the Applications directory, we could simply move it or copy/paste it to another directory outside Applications and when launching it from that new location the issue was resolved.
Seems like there is something specific to the default Applications directory that is causing this to happen(as odd as that sounds). Keep in mind that even when the app is installed in the Applications directory, this issue only happens to 7 people out of over 4,000.
Any ideas as to what might be special about that directory that could explain what we're seeing?

App approved, but crashes

I have made a Windows Phone app (for WP7.1) that uses BackgroundAudio for streaming, nothing too complicated. It was approved and made available for download in the store. However it no longer works, i.e. the app worked in debug+release when run from VS2012, and I assume the .xap I uploaded worked since microsoft approved it (they rejected it once and I was able to reproduce and fix the bugs they reported).
When downloaded the app simply bails on load on WP8 (lumia 820) i.e. flips back to the tiles immediately.
On WP7 (lumia 800) but the playbutton ignores input, however it downloads and displays the playlist, so some kind of functionality+network connection works.
I have tried the basics: installing using the application-deployment tool (app working), running the "Store Test Kit" which reports some slowdowns in the UI animations, but nothing serious (I hope).
Any ideas how to reproduce ".xap approved and downloaded from store but not working" or getting debug info from the phone without VS? Or any other things i can try out?
Every time your app crashes it will be logged and reported on your Windows Phone Dev Center Account. Just go in there and export the details to excel. Get the stack trace and put it in here. Maybe we can help.
The very first thing i can tell you is the opening page has some exceptions and that too it doesn't go well with some phones. Seriously there are concerns when a wp7 app is ported on wp8 device and vice-verse. To the extent of my knowledge there might be some binding issues. make sure you got the binding class to be public. And just as #AMR mentioned go the dev center and export the stacktrace. Try resolving them. Moreover if an app get certifies, it doesn't mean it is completely error free. The tests are limited to very coomon errors only.

WP Mobile Detector, W3 Total Cache, Home Page, Blackberry Viewport, Responsive

I'm using WP Mobile Detector with W3 Total Cache and a responsive layout (media queries), and I have a few issues:
When I view the site locally (localhost) on a Blackberry, it looks good; the zoom/viewport is correct, media queries have trigger correctly etc. However, when I view the live site on the Blackberry, the viewport has zoomed out. In the context of a responsive layout, locally I see two columns, but on live I see all six columns (i.e. the Blackberry thinks it is a full browser - quite annoying!).
I thought I would deactivate W3 Total Cache to see if that was having any effect: yes, it was. When the cache is off, the viewport/zoom is good and all is well. Problem solved? Not quite...
With the cache off, I navigate to the live site and while the sub-pages of the site - e.g. www.SITE.com/about, www.SITE.com/contact - are responding with the mobile theme, when I click a link back to home (or type it into the address bar) - i.e. www.SITE.com/ - I'm no longer delivered the mobile theme, just the normal 'desktop' theme. If I go back to a sub-page I see the mobile theme again. What's going on there then.
When viewed on the Blackberry (for example), if I click the 'View Full Site' link (which triggers a Javascript function to modify the cookie) it doesn't show the full site (i.e. normal theme), it just refreshes and shows the mobile theme. However, when viewed in Firefox on the desktop (via a User Agent Switcher) the link DOES modify the cookie and switches back to the normal desktop theme.
Thoughts/Questions
W3TC does work with WPMD (mobile theme delivers minified JS/CSS), but maybe I haven't configured something correctly. The following two links were very useful and I have implemented the changes suggested:
--- http://snipplr.com/view/47970/wp-mobile-detector--w3-total-cache-integration/
--- http://journal.code4lib.org/articles/6223
Is this a known [Blackberry HotSpot/Internet Browser] issue? I have added the requisite meta tags in the document head to indicate viewport data, and the HandheldFriendly meta data which I understand is mainly for Blackberry purposes. As I said, it looks ok with the cache switched off, excepting the home page issue.
I should say it works nicely in Firefox with the User Agent Switcher extension set to iPhone 3, and I have none of the Blackberry issues.
WPMD works by setting a cookie. This appears to be working, else I wouldn't have seen the mobile theme at all.
Does the Blackberry have a problem with the Javscript function? Not easy to tell from the phone itself - might need to drop in a JS error monitor (I was looking at one the other day).
Who'd have thought mobile dev would be so tricky!
UPDATE 1
It's a few weeks since first posting, and I will soon be following Joshua and Frederick's advice to uninstall and then reinstall the [latest version of] W3TC and I'll post my results.
I found that different browsers (both desktop and mobile) treat javascript redirect statements differently. For example:
setTimeout(function(){window.location.reload();},10)
window.location.reload();
location.reload();
The three lines above effectively perform the same action (slightly different implementations, depending on your needs), but I had varying success across browsers using each one - Chrome worked with one, Firefox another, etc.. Unfortunately, I still could not get the Blackberry browser to perform a proper automatic refresh via Javascript.
What else...so, switching between desktop and mobile using a desktop PC/browser has proven interesting. Let's say we're on the desktop version, and we switch to the mobile version of the page. We're OK so far, but then we switch back to the desktop version of the page. Still OK, but if we quickly click a link on the desktop page to go to another [desktop] page then we may find ourselves looking at the mobile version instead of the desktop version.
So, what happened there? As the page was still loading when we clicked another link, did we interrupt something? Presumably not, as the cookie would have been set and sent in the previous request from the mobile version of the page to say, e.g., "show-desktop-version = true". If we do hit F5 or the browser's 'Refresh' button (or, in fact, a link to any other page) then we do see the correct mobile or desktop version (respectively).
Another interesting thing: say we're on our mobile version (using desktop browser), and we're looking at site.com/mypage, and on the page is a link to 'View Full Site' (VFS). We click VFS once and it refreshes but we're still seeing the mobile version. So we click again - same result. So we click again, and again, and again, and again, and - oh, OK this time it switched to the full site. This cycle/process seems to occur once, and then not for a while, and then happens again.
UPDATE 2
Regarding the mobile-desktop theme switching problems, please disregard my notes in 'Update 1'. One of my switcher links (from desktop theme to mobile), e.g....
View Mobile Site
...was using the query parameter (as you can see). I had used this technique to test whether a mobile browser was preventing a proper refresh as the link pointed to the same/current URL. The switcher link should have actually looked like this,
View Mobile Site
...with just a hash to allow the link to be clickable, while allowing the Javascript function to do its magic (update cookie, reload page).
Problem resolved.
(W3TC + WPMD compatibility still an issue for me - will post updates).
I am the developer of the WP Mobile Detector.
The issues you describe are exactly what happens when the W3 Total Cache is installed. For whatever reason, sometimes it is necessary to deactivate and delete the W3 Total Cache.
Two customers that I can remember reported issues even when the W3 Total Cache was disabled. Once it was removed, it fixed the problem. They then re-uploaded W3 Total Cache, made the changes at the link you posted, and seemed to be fine.
For whatever reason these issues seem to be more prevelant with newer versions of the W3 Total Cache. I need to get with Frederick (the creator of W3 Total Cache) and make sure the plugins play nice together.
Make sure to clear your cache on the BlackBerry device as well.
Without evaluating the plugin there are some things to consider here. First W3TC attempts by default to set a cookie to properly determine which page cache to use for user agent groups for smartphones and less-smart phones; it keeps unique caches for each because of the popularity of mobile theme plugins prior to popularity of responsive web design and progressive enhancement.
The user agent groups can be disabled or used to redirect visitors to another page or theme. The next release also removes the need for the cookie when user agent groups are set. A future release will also allow cookies to be used to unique cache user requests as well.

WP7: Edit Screenshot While App is Backgrounding (Mango)

I have an app that I have been developing that can display sensitive user data.
When the user backgrounds the app, the OS appears to take a screenshot of the app as it was running, and displays it so when the user returns, their state is restored.
I am trying to prevent the user's information from being seen in this screenshot.
My initial idea was to display a Popup of my splash screen image, but it does not seem to render it in ApplicationDeactivated. Is there any other way you might accomplish this?
I am not sure you are analyzing this correctly. I don't see how the OS could take a screenshot of an app and use that to restore state. Also, if it was true that the OS did that, Tomb Stoning wouldn't be such a big issue in the requirements for an app in the submission process. A dev needs to handle grabbing and saving state on exit and reloading it on start-up again.
If you didn't code this tomb stoning, are you using a frameowrk that has built in support for this? You could disable the tombstoning so certain pieces of information are not stored, and in fact if this data is that sensitive you should make sure it isn't saved. But, if you save it make sure you encrypt it so nothing else could examine the saved state. Although, that shouldn't be possible on Win Phone as the OS is supposed to enforce the boundries between apps.
Received a response from Microsoft which indicates that this is not possible in the Mango SDK; it may be added into future releases of the platform.

Resources