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

chore(android): optimize proxy constructor lookup #12774

Merged
merged 10 commits into from Sep 10, 2021

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented May 5, 2021

  • Minor optimization for V8 proxy constructor lookup
  • Prevent unnecessary GetPropertyNames() call
  • Correctly sets prototype constructor
    • This means exports->GetConstructorName() returns the proxy name
Related Object.constructor
TEST CASE
const win = Ti.UI.createWindow();
const label = Ti.UI.createLabel();
const label_derived = new label.constructor({ text: 'This is derived from a constructor.' });

console.log(`label.constructor: ${label.constructor}`);
console.log(`label_derived.constructor: ${label_derived.constructor}`);

win.add(label_derived);
win.open();

JIRA Ticket

@@ -70,6 +70,7 @@ void ${className}::bindProxy(Local<Object> exports, Local<Context> context)
moduleInstance.Reset(isolate, instance);
<#else>
exports->Set(context, nameSymbol, constructor);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Can't remove this line as it's necessary for modules

@build
Copy link
Contributor

build commented May 5, 2021

Messages
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖

✅ All tests are passing
Nice one! All 19504 tests are passing.
(There are 1162 skipped tests not included in that total)

📖

💾 Here's the generated SDK zipfile.

Generated by 🚫 dangerJS against 015e292

@jquick-axway
Copy link
Contributor

@garymathews, this change somehow prevents our "bootstrap.json" from being read on app startup. It happens to both encrypted and unencrypted builds. The following error will be logged, which you can see in Jenkins' output. I'm seeing this error on my end too.
Failed to read "bootstrap.json". Reason: Unexpected token u in JSON at position 0

@jquick-axway
Copy link
Contributor

This causes our "hyperloop-examples" sample app to crash.

[ERROR] TiExceptionHandler: (main) [37,513] /hyperloop/android.app.Activity.js:28
[ERROR] TiExceptionHandler: 		result = Activity.class.newInstance(arguments);
[ERROR] TiExceptionHandler:                           ^
[ERROR] TiExceptionHandler: TypeError: Activity.class.newInstance is not a function
[ERROR] TiExceptionHandler:     at new Activity (/hyperloop/android.app.Activity.js:28:27)
[ERROR] TiExceptionHandler:     at Object.isInstalledViaGooglePlay (/google-play-utils.js:10:16)
[ERROR] TiExceptionHandler:     at Window.onOpen (/alloy/controllers/index.js:122:59)
[ERROR] TiExceptionHandler:     at Window.value (ti:/kroll.js:1604:27)
[ERROR] TiExceptionHandler:     at Window.value (ti:/kroll.js:1656:25)
[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:63)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:985)
[ERROR] TiExceptionHandler:     org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1219)
[ERROR] TiExceptionHandler:     org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:260)
[ERROR] TiExceptionHandler:     ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:481)
[ERROR] TiExceptionHandler:     android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiExceptionHandler:     android.os.Looper.loop(Looper.java:223)
[ERROR] TiExceptionHandler:     android.app.ActivityThread.main(ActivityThread.java:7664)
[ERROR] TiExceptionHandler:     java.lang.reflect.Method.invoke(Native Method)
[ERROR] V8Exception: Exception occurred at /hyperloop/android.app.Activity.js:28: Uncaught TypeError: Activity.class.newInstance is not a function

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR/FR: Pass

Tested the following:

  • kitchensink-v2
  • hyperloop-examples
  • Building module "ti.map" with this PR and using it in a 10.1.0 and 9.1.0 built app.

Copy link
Collaborator

@ewanharris ewanharris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR Pass, in addition to Josh's testing I also tested webpack and liveview usage

@ewanharris ewanharris merged commit 54132d2 into tidev:master Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants