At the end of November, the company I work at, Mindflash, released an iPad app. We built it primarily in AngularJS with some native hooks where we needed them. I’m sure I’ll expand more on this in the future but here are 3 quick things I (and I’m sure all of my colleagues) wish I knew prior to starting on the project. Perhaps they’ll help your in your own future projects.
- BEWARE IFRAMES!
iOS Safari chokes on iframes. We found iframes to be a constant source of pain causing seemingly every problem from using an inordinate amount of memory to making a vertically scrolling div rendered on the page completely outside of the iframe only scrollable by swiping horizontally (WAT!?!).
Given the huge number of APIs that use iframes, you can find yourself running into this problem a lot. Even worse for us was that the way in which we were originally communicating from the WebView to the native app was by changing the URL of an iframe in our app. In the end we removed all dependencies on iframes aside from embedding YouTube videos and have never been happier.
- Serving your local app from file:// uses a lot more memory than from a web server
I don’t understand why this is, but the difference is substantial. We saw a drop of around 20-25 MBs of memory usage which is huge on iOS and particularly on the iPad 1.
So how does one serve their app from the iPad’s file system without using file://? By using an iPad-based HTTP server of course! We used the open source CocoaHTTPServer.
- The iPad 1 Is the new IE6
It seems no matter what you do to improve your app’s reliability and performance it will crash on the iPad 1 much more often than any of the later generations. This is due in part to the tighter memory constraints but also due to the fact that many people’s iPad 1’s were hosed on upgrade to iOS 5. Check out this thread for one of many discussions on the issue.
There are lots of reports of people primarily on the iPad 1 but also on the iPad 2 seeing Safari (and thus WebView) crashes with breathtaking frequency after upgrading to iOS 5. Since the only guaranteed solution is resetting the iPad with iOS 5, you’ll run into plenty of users who haven’t done that and have just lived with it and there’s nothing you can do about it.
I hope this helps anyone building a hybrid app today. We’ve been thrilled with our decision to architect it this way. Again, I’ll follow up with future posts on the development of our iPad app. Perhaps the next one will be on things I wish we knew how to do – like how the hell do YouTube and Netflix serve their streaming video so quickly?