Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Javascript code in a native app

749 views

Published on

By Kevin Read

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Javascript code in a native app

  1. 1. Javascript code in anative appGraphically intensive and interactiveKevin Readkread@boerse-go.de@unverbraucht
  2. 2. Javascript rocks● Its great○ fast○ cross-platform○ runs (nearly) everywhere● So we built a Canvas-based chart analysistool in JS with a gazillion features:○ Quick demo
  3. 3. ● On mobile, canvas not there yet for us○ 2-3 fps performance○ Differences in touch handling over browsers● Porting not an option○ 30k LOC of JS times two platforms● Idea: Reuse JS version○ Embed JS VM into app, here v8○ Custom code for canvas, AJAX, websocket, ...JS isnt for everything
  4. 4. Android embedding architectureDalvik VM(Java) App (Views, Activities)
  5. 5. Android embedding architectureDalvik VM(Java)v8Engine singletonJNI(C/C++) BGJSContextv8(JS)JS ChartApp (Views, Activities)initializesload andexecuterequiresOther JS files
  6. 6. Android embedding architectureDalvik VM(Java)v8Engine singletonJNI(C/C++) BGJSContextv8(JS)JS ChartBGJSModulesApp (Views, Activities)initializesEjecta + BG(Canvas inOpenGL)register asJS functionsload andexecuteOther JS filesrequires
  7. 7. Android embedding architectureDalvik VM(Java)v8Engine singletonJNI(C/C++) BGJSContextv8(JS)JS ChartBGJSModulesApp (Views, Activities)initializesv8TextureView(GL init, pageflip,touch, ..)addsEjecta + BG(Canvas inOpenGL)register asJS functionsload andexecuteOther JS filesrequires
  8. 8. Android embedding architectureDalvik VM(Java)v8Engine singletonJNI(C/C++) BGJSContextv8(JS)JS ChartAjax Helper(threading, IO, ...)BGJSModulesApp (Views, Activities)initializesv8TextureView(GL init, pageflip,touch, ..)addsAjaxModuleEjecta + BG(Canvas inOpenGL)register asJS functionsload andexecuteAuthModule...Other JS filesrequires
  9. 9. DemoFinger crossing plz.
  10. 10. Lessons learned and end● Embedding a JS VM is a big to epic win○ Performance gain x20 (!)○ Oh, and works on x86 too of course :D● But plan to take some time:○ v8 is great, but steep learning curve.○ Debugging JNI/NDK can be very painful.Thanks for your time.@unverbraucht+Kevin Read: http://gplus.to/unverbrauchtEjectaJS for iOS: http://impactjs.com/ejectaMartins stuff: https://github.com/Tharitgplus.to/unverbraucht

×