At SDK build time, ./android/titanium/prebuild.js script is run which takes JS files (from ./android/runtime/common/src/js) and generates C char*
- This is done to "bake in" the source to avoid disk I/O slowdown
App.java
- create app info, set up encryption asset helper stuff
- create asset cache
- load Ti.App data into analytics class
- create V8Runtime
- register external modules (id -> class)
- then call...
V8Runtime#nativeInit()
- from java down to JNI
- sets up platform, isolate, debugger, then calls...
V8Runtime#bootstrap() - sets up
EventEmitterin C code - creates kroll object, calls into
KrollBindings.cppto hangbinding/externalBindingfunctions for grabbing a builtin/native module - hangs
EventEmitter,DBG,runtime,logmethod properties offkrollobject- (Note that
kroll.logmay not add newlines at end?)
- (Note that
kroll.js is parsed then invoked
- holds a function that does initial kernel bootstrapping
- creates a
global.krollobject - hangs
NativeModuleoff of it which is a way to load the baked in JS code from build time - hangs
global.Tifrom loading baked-intitanium.js- This ends up calling
KrollBindings#initTitanium()which sets upProxy/KrollProxy/KrollModule/TitaniumModulein C - Also does bootsrapping of other baked in JS code for extensions like ui/network/properties/locale
bootstrap.jsfile is loaded?!
- This ends up calling
- hangs
global.Modulefrom loading baked-inmodule.js- This effectively sets up our
require()implementation
- This effectively sets up our
- hangs
global.consolefrom loading baked-inconsole.js- piggy-backs on
Ti.API
- piggy-backs on
back to V8Runtime#bootstrap()
- set up
global.global - set default
global.__dirnameand__filename
back to java V8Runtime#initRuntime()
- start debugger
- load external native modules
... then?
- The root splash screen activity
TiLaunchActivitycallsTiApplication.launch()to start the JS runtime. - which eventually calls from Java -> JNI -> C to
global.Module.runModule()(or if we have a snapshot, it doesglobal._startSnapshot(global)) - When
TiLaunchActivityis destroyed, the JS runtime will be terminated.