architecting cross platform mobile frameworks
play

Architecting Cross-Platform Mobile Frameworks Spencer Chan Quora - PowerPoint PPT Presentation

Architecting Cross-Platform Mobile Frameworks Spencer Chan Quora Motivation Two extremes Fully native Fully HTML+JS How can we get the best of both worlds? Motivation Two extremes: Fully native Fully


  1. Architecting Cross-Platform Mobile Frameworks Spencer Chan – Quora

  2. Motivation Two extremes ● Fully native ○ Fully HTML+JS ○ How can we get the best of both worlds? ●

  3. Motivation Two extremes: ● Fully native ○ Fully HTML+JS ○ How can we get the best of both worlds? ● For the last 3 years, Quora has used a custom hybrid ● framework We're very happy with it ○

  4. Agenda 1. How Quora's app works 2. Design Decisions 3. Learnings from the past 3 years

  5. Takeaways What can you expect if you follow the same path we did? ● Is this approach worth exploring for your apps? ● What should you look for in a publicly available ● framework? Are you better off building your own? ○

  6. How it Works

  7. This is a question page

  8. This is a question page Webviews outlined in red

  9. Meanwhile on the Server The webview loads a url ● The page is rendered by a tree of ● component objects This component is used across all platforms ●

  10. After page load

  11. After scrolling to the end of the answer

  12. Pressing the button HTML + CSS

  13. Pressing the button HTML + CSS + JS

  14. Pressing the button HTML + CSS + JS No native code involved at all!

  15. Now for a different example...

  16. Here's a user profile page

  17. Tapping here is going to show a menu ...

  18. Native menu

  19. Native menu

  20. Message Passing

  21. Message Passing

  22. Message Passing Implemented differently for each platform ● Asynchronous message passing is more future proof ● Minimal, but can build on top of this ●

  23. Abstraction is your friend Android iOS Java Obj-C/Swift Application JavaScript

  24. Abstraction is your friend Web Android iOS Framework Java Obj-C/Swift JavaScript Application JavaScript

  25. Abstraction is your friend Abstracting away platform specific code simplifies the remaining ● application code Also useful for cross-browser compatibility ● This is one of the main benefits of things like jQuery ○

  26. Design Decisions

  27. Design Decisions 1. HTML Content 2. Native Navigation 3. No Page Types

  28. HTML Content Webviews outlined in red

  29. HTML Content HTML + CSS + JS No native code involved at all!

  30. HTML Content Alternative: native views powered by shared application code ● HTML views increase potential code sharing with websites, if you ● have one Client side vs. Server side rendering ○ HTML is great for text-heavy products like Quora ●

  31. Design Decisions 1. HTML Content 2. Native Navigation 3. No Page Types

  32. Native Navigation Each navigation creates a new webview and adds it to the ● native navigation stack. Pros ● Native gestures ○ Native animations ○ Cons ● Makes prefetching harder ○ More native code, less code sharing ○

  33. Native Navigation

  34. Native Navigation

  35. Native Navigation

  36. Design Decisions 1. HTML Content 2. Native Navigation 3. No Page Types

  37. Native UI Examples: How do we implement this?

  38. Solution 1: Page Types "This is the notifications page" ● Native code knows it should have certain buttons and styling ○

  39. Solution 2: No Page Types "Native UI should have these buttons and this styling" ● Native code doesn't need to know about notifications ○ This makes it easier to maintain a strong abstraction barrier ● Useful if you expect to add or modify page types often ●

  40. Avoid Message Thrash Backwards compatibility is painful ● Easier to do without page types, but still a concern ● Avoid UI thrash! ●

  41. Design Decisions 1. HTML Content 2. Native Navigation 3. No Page Types

  42. Learnings

  43. Learnings 1. Be prepared to deal with webview quirks 2. Demystify loading slowness 3. Code sharing goes deeper than views 4. JavaScript lets everyone contribute

  44. Webview Issues Problem: ● Spike in crash reports saying app ran out of memory ○ Solution: ● It was a new image loader we were trying out ○ Don't load images in JS on that webview implementation ○

  45. Webview Issues Our webviews have an animated loading screen (the 3 dots in the middle are animated)

  46. Webview Issues Problem: ● We want to fade out the loading screen as soon as any content is ○ visible in the webview But we can't tell from native code when webview has started ○ displaying content Solution: ● Poll the webview pixel to see when they start changing ○

  47. Learnings 1. Be prepared to deal with webview quirks 2. Demystify loading slowness 3. Code sharing goes deeper than views 4. JavaScript lets everyone contribute

  48. Real issues caused by webviews Bandwidth ● HTML is bigger than JSON ○ Multiple roundtrips ● Blocking on CSS/JS ○ Web performance could be the subject of a whole separate talk ○

  49. Issues unrelated to webviews Latency ● Loading images from a server on the other side of the ○ world will be slower than loading them from a CDN Slow application code ● Example: not paginating data ○ Again, this could be a whole separate talk ○

  50. Be scientific and rigorous Find the real root causes of your performance problems

  51. At least there's only one thing to optimize Our app will have performance in the same ballpark as our ● mobile website We have a mobile website and care about its performance ● All of our speed efforts are going towards the same thing ●

  52. Learnings 1. Be prepared to deal with webview quirks 2. Demystify loading slowness 3. Code sharing goes deeper than views 4. JavaScript lets everyone contribute

  53. Shared infrastructure At Quora, the same boxes handle all platforms ● No API tier ○

  54. Shared deployment tools We share the same continuous deployment system we use on web

  55. Shared UI integration tests If there are 100 buttons and 3 platforms, do you need 300 tests? ● Or just 102 ●

  56. Learnings 1. Be prepared to deal with webview quirks 2. Demystify loading slowness 3. Code sharing goes deeper than views 4. JavaScript lets everyone contribute

  57. Javascript lets everyone contribute

  58. Javascript lets everyone contribute Easy ramp-up ● Designers code ● Few projects get blocked on native development ●

  59. Learnings 1. Be prepared to deal with webview quirks 2. Demystify loading slowness 3. Code sharing goes deeper than views 4. JavaScript lets everyone contribute

  60. Conclusion There are pros and cons to any architecture ● This one has worked very well for us over the last 3 years ● If you haven't tried hybrid app development, maybe it's worth ● considering or exploring either by building your own framework, or using a publically ○ available one

  61. Questions?

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend