82 points · by aaronbrethorst · 14y ago · 30 comments
For every web-based iOS app that's clunky and slow like Facebook, there's another one like Quora or OKCupid or even the iOS App Store that is almost indistinguishable from a native app, save for a few minor telltale giveaways (one of the most common ones is showing a loading icon while you load in an entire view instead of rendering a view's components piecemeal as they're ready).
The problem is that many developers who go with a hybrid app solution do so because they think it'll be easier or quicker than an all-native app, especially if they need multiplatform support. Doing a hybrid app correctly can in many cases require much more work than simply doing a native app, both technically (there are a lot of very tricky caching issues, since UIWebViews don't properly handle cache manifests) and design-wise in terms of nailing the behavior and feel of a native app. Hybrid apps are neither a complete usability disaster nor a silver bullet that gives you a 'write once, run anywhere' utopia.
I agree with you on the last part though. I'd recommend native app with a good design that makes it flexible via server changes. For big changes, the app store updates is usually just a one week process anyway
Are we using the same app store? It's awful! It's painfully slow and it frequently 'forgets' what I was doing when I press the back button after viewing an app's details (search filters and list positions, to name a few).
It's not the most obvious UIWebView-wrapped app ever, but it's still fairly evident.
I have only ever seen one hybrid app done well - and that's the LinkedIn app. Every single other hybrid app (including Apple's own App Store!) is slow, buggy, and just unpleasant to use.
Either way, they obviously need to fail a little more gracefully, which should be a solvable problem.
IMHO, hybrid apps would be much nicer if UIWebView could just manage its appetite for RAM a little better.
The advantage of using native controls it it provides a much greater integration with the rest of the operating system, and makes it easier to make your app work in the same manner as other apps. For example, there are many features of iOS that are not exposed through javascript APIs, and for that you have no option but to use native code. Nonetheless, I like what Microsoft is doing with providing javascript APIs for metro development, and though I haven't tried it myself, it looks like a good approach.
There are a number of serious problems with the current UIWebView which are also holding it back as development tool:
- You have very limited control over touch events. In my case, I completely disabled all default event handling on the web view, and implemented my own touch event handlers in Objective C, which pass the events through to javascript.
- Selection is broken. You can access the selection, but not modify it. I spent several weeks completely reimplementing the selection & cursor mechanism because of this. One positive outcome though was it gives me much more fine-grained control over user interaction issues.
- contentEditable is also broken. I spent probably 3-4 months reimplementing this functionality myself in javascript to make it usable
- Interfacing between Objective C and Javascript is tricky. Going from ObjC -> JS is fast, but going in the other direction using the technique from the article is painfully slow. There a ways to work around this but it's inelegant and doesn't allow return values from callback functions.
- Lack of Nitro support, as discussed elsewhere. It turns out that for my particular needs performance is quite acceptable, but for more compute-intensive apps like games it's a must. I can understand Apple's desire to prevent W+X permission on memory, but this could be solved by running JS code in a separate process and communicating with the host process via shared memory.
Apple have done some amazing things with WebKit, but the iOS port leaves a lot to be desired. I would really like to see them improve these apps so people can better integrate web content & backend functionality. But I still think you should be using Cocoa Touch for your UI.
But as other commenters have noted, it should never be seen as a "time-saver" for anything beyond trivial functionality; the little quirks of each browser runtime must be paid their due, with the user experience and performance in mind.
My one complaint is that he doesn't seem to acknowledge the possibility of a "minimal Objective-C" app (i.e. mostly HTML-based) that is tailored to iOS and uses in-app storage for most of the UI elements. We need more discussion on methods to make the mostly-HTML approach to work better. The post is a great start.
By far, the biggest improvement one can do is to get rid of the 300ms or so delay on a UIWebView
The solution to this, if you're not using double-taps, is to respond to the event when it enters the initial phase (then the finger is pressed), rather than when it's released. I'm not sure if you can do this through javascript, but I know it's possible in Objective C by either overriding – touchesBegan:withEvent:, or implementing your own gesture recogniser.