[TIMOB-23744] Android: Crash using Ti.Android.R values
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-08-10T13:09:14.000+0000 |
Affected Version/s | Release 6.0.0 |
Fix Version/s | Release 6.0.0 |
Components | Android |
Labels | n/a |
Reporter | Martin Guillon |
Assignee | Christopher Williams |
Created | 2016-08-08T18:14:28.000+0000 |
Updated | 2016-09-15T23:59:53.000+0000 |
Description
When accessing Ti.Android.R values in your app, it causes a crash. Something as simple as:
console.log(Ti.Android.R.anim);
[INFO] : art: art/runtime/runtime.cc:289] native: #11 pc 002b913a /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (_JNIEnv::CallObjectMethod(_jobject*, _jmethodID*, ...)+42)
[INFO] : art: art/runtime/runtime.cc:289] native: #12 pc 0030c0a7 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (titanium::RProxy::interceptor(v8::Local<v8::String>, v8::PropertyCallbackInfo<v8::Value> const&)+215)
[INFO] : art: art/runtime/runtime.cc:289] native: #13 pc 00853563 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::PropertyCallbackArguments::Call(void (*)(v8::Local<v8::Name>, v8::PropertyCallbackInfo<v8::Value> const&), v8::internal::Handle<v8::internal::Name>)+179)
[INFO] : art: art/runtime/runtime.cc:289] native: #14 pc 008d3669 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSObject::GetPropertyAttributesWithInterceptor(v8::internal::LookupIterator*)+1353)
[INFO] : art: art/runtime/runtime.cc:289] native: #15 pc 008f3cf3 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSReceiver::GetPropertyAttributes(v8::internal::LookupIterator*)+67)
[INFO] : art: art/runtime/runtime.cc:289] native: #16 pc 008f4cef /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSReceiver::GetOwnPropertyDescriptor(v8::internal::LookupIterator*, v8::internal::PropertyDescriptor*)+127)
[INFO] : art: art/runtime/runtime.cc:289] native: #17 pc 008fdbf6 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSReceiver::OrdinaryDefineOwnProperty(v8::internal::LookupIterator*, v8::internal::PropertyDescriptor*, v8::internal::Object::ShouldThrow)+86)
[INFO] : art: art/runtime/runtime.cc:289] native: #18 pc 008fdd61 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSReceiver::OrdinaryDefineOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSObject>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDescriptor*, v8::internal::Object::ShouldThrow)+209)
[INFO] : art: art/runtime/runtime.cc:289] native: #19 pc 008feab0 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::JSReceiver::DefineOwnProperty(v8::internal::Isolate*, v8::internal::Handle<v8::internal::JSReceiver>, v8::internal::Handle<v8::internal::Object>, v8::internal::PropertyDescriptor*, v8::internal::Object::ShouldThrow)+80)
[INFO] : art: art/runtime/runtime.cc:289] native: #20 pc 004d0c12 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::Object::DefineOwnProperty(v8::Local<v8::Context>, v8::Local<v8::Name>, v8::Local<v8::Value>, v8::PropertyAttribute)+402)
[INFO] : art: art/runtime/runtime.cc:289] native: #21 pc 002c05d1 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (titanium::Proxy::proxyConstructor(v8::FunctionCallbackInfo<v8::Value> const&)+289)
[INFO] : art: art/runtime/runtime.cc:289] native: #22 pc 004e1034 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))+148)
[INFO] : art: art/runtime/runtime.cc:289] native: #23 pc 00540994 /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (???)
[INFO] : art: art/runtime/runtime.cc:289] native: #24 pc 00540eac /data/app/com.appcelerator.sample.ti520-1/lib/x86/libkroll-v8.so (???)
From comments on the Github PR: https://github.com/appcelerator/titanium_mobile/pull/8041#issuecomment-238030109 Looks like this is a generic problem with "interceptors" with the latest V8. From that stack trace it appears that during the proxy constructor we're defining properties, and that somehow triggers the interceptor in the middle of it. The interceptor callback method tries to unwrap the proxy from he JS object and crashes doing so? I see this locally:
Looks to be an issue when we're constructing objects with order of when things happen. Basically we need to ensure we've wrapped the JS object in a C++ Proxy object and then that we create a Java object to pair with the JS object - before we ever try to call any methods on this proxy. I can move the Proxy wrapping up over the DefineOwnProperty call, to fix the Proxy::unwrap() call failing, but then the JNI invocation on the interceptor fails because the Java object is null. So I can: eliminate the call to DefineOwnPrperty to define the internal _properties object in every proxy instance. Then I guess I'd have to modify any code that used that to assume it may not exist and to initialize it first. Or I can make the interceptor code know to check for a null Java object and return early.
https://github.com/appcelerator/titanium_mobile/pull/8195
Once the PR is confirmed/merged, it needs to be cherry-picked to master branch.
Verified the fix.
Ti.Android.R
values do not cause crash. Closing. Environment: Appc Studio : 4.8.0.201609061702 Ti SDK : 6.0.0.v20160915125929 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-6 Appc CLI : 6.0.0-44 Node: 4.4.4 Nexus 6 - Android 6.0.1