Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): support circular require references #11693

Merged
merged 21 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e932694
feat(ios): move to JS based require implementation
sgtcoolguy Apr 17, 2019
bacfd58
test: add test for circular require
sgtcoolguy May 7, 2020
f450253
refactor(ios): rip out native require move to js entirely
sgtcoolguy May 19, 2020
c6ea077
refactor(js): create a common kernel/bootstrap
sgtcoolguy May 12, 2020
ec4c5c0
docs: add details on common folder contents
sgtcoolguy May 14, 2020
deb41c9
build: output a kernel/bootstrap rollup bundle
sgtcoolguy May 12, 2020
94658a7
refactor(ios): use a bootstrap JS file before loading ti.main.js
sgtcoolguy May 12, 2020
c7790f6
fix(ios): implement Ti.Blob binary toString natively
sgtcoolguy Aug 31, 2020
f6a3f5c
docs: add notes about the workflow for android startup
sgtcoolguy Dec 18, 2019
13d88e2
refactor(android): move kroll.js to common
sgtcoolguy May 15, 2020
29fb58d
refactor(android): define Ti.Android.currentService in Module.runModule
sgtcoolguy May 15, 2020
05b84e3
fix(ios): detect when ios has service
sgtcoolguy May 15, 2020
fa8de6c
refactor(android): remove unused moduleContexts
sgtcoolguy May 19, 2020
d62759b
refactor(android): move most js ti extensions to common
sgtcoolguy May 18, 2020
4b09ed2
fix(android): override global.L behavior for non-string default values
sgtcoolguy Jul 29, 2020
d481a8d
fix(android): fix Ti.Blob.arrayBuffer definition
sgtcoolguy Aug 31, 2020
61fb51c
feat(ios): add KrollPromise to expose ES6 promises natively
sgtcoolguy Jul 10, 2020
a88948e
fix(ios): implement Ti.Blob.arrayBuffer natively
sgtcoolguy Aug 31, 2020
bdee7ff
fix(android): explicitly define Ti.Android.currentService to be null …
sgtcoolguy Dec 15, 2020
ca311a8
build: wipe tmp dir on clean
sgtcoolguy Jan 12, 2021
1d69030
docs: remove outdated test override README
sgtcoolguy Jan 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 51 additions & 0 deletions STARTUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# iOS vs Android startup notes

## Android

### Build time
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
sgtcoolguy marked this conversation as resolved.
Show resolved Hide resolved

### Runtime
`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...
sgtcoolguy marked this conversation as resolved.
Show resolved Hide resolved

`V8Runtime#nativeInit()`
- from java down to JNI
- sets up platform, isolate, debugger, then calls...
`V8Runtime#bootstrap()`
- sets up `EventEmitter` in C code
- creates kroll object, calls into `KrollBindings.cpp` to hang `binding`/`externalBinding` functions for grabbing a builtin/native module
- hangs `EventEmitter`, `DBG`, `runtime`, `log` method properties off `kroll` object
- (Note that `kroll.log` may not add newlines at end?)

`kroll.js` is parsed then invoked
- holds a function that does initial kernel bootstrapping
- creates a `global.kroll` object
- hangs `NativeModule` off of it which is a way to load the baked in JS code from build time
- hangs `global.Ti` from loading baked-in `titanium.js`
- This ends up calling `KrollBindings#initTitanium()` which sets up `Proxy`/`KrollProxy`/`KrollModule`/`TitaniumModule` in C
- Also does bootsrapping of other baked in JS code for extensions like ui/network/properties/locale
- `bootstrap.js` file is loaded?!
- hangs `global.Module` from loading baked-in `module.js`
- This effectively sets up our `require()` implementation
- hangs `global.console` from loading baked-in `console.js`
- piggy-backs on `Ti.API`

back to `V8Runtime#bootstrap()`
- set up `global.global`
- set default `global.__dirname` and `__filename`

back to java `V8Runtime#initRuntime()`
- start debugger
- load external native modules

... then?
- The root splash screen activity `TiLaunchActivity` calls `TiApplication.launch()` to start the JS runtime.
- which eventually calls from Java -> JNI -> C to `global.Module.runModule()` (or if we have a snapshot, it does `global._startSnapshot(global)`)
- When `TiLaunchActivity` is destroyed, the JS runtime will be terminated.
114 changes: 0 additions & 114 deletions android/modules/ui/src/js/ui.js

This file was deleted.

24 changes: 0 additions & 24 deletions android/modules/ui/src/js/webview.js

This file was deleted.