Android-runtime: Wrong object lifecycle management

Created on 15 Mar 2016  路  21Comments  路  Source: NativeScript/android-runtime

Reported from @wisonye https://github.com/NativeScript/NativeScript/issues/1705

The test phone is a Huawei P8 lite version( Android 5.0 ), it's very easy to re-show the issue, just like my loginUI, if I do type in the "password" field, it will crash( sometimes need to long press to show up the "copy/paste" floating mean to cause crash ), UI super simple, looks like this:

https://drive.google.com/file/d/0B-AooW_48tzISmZCbnNNeDB2ZUU/view?usp=sharing

And here is the crash log output, if your team found something, that's good, if have no idea, then just ignore it, I just want to do a "potential bug report" :)

com.tns.NativeScriptException: No weak reference found. Attempt to use cleared object reference id=366
at com.tns.Platform.getJavaObjectByID(Platform.java:633)
at com.tns.Platform.callJSMethodNative(Native Method)
at com.tns.Platform.dispatchCallJSMethodNative(Platform.java:812)
at com.tns.Platform.callJSMethod(Platform.java:711)
at com.tns.Platform.callJSMethod(Platform.java:690)
at com.tns.Platform.callJSMethod(Platform.java:680)
at com.tns.gen.android.text.TextWatcher_ftns_modules_ui_editable-text-base_editable-text-base_l22_c29__.afterTextChanged(android.text.TextWatcher.java)
at android.widget.TextView.sendAfterTextChanged(TextView.java:7771)
at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9563)
at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:976)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:520)
at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:216)
at android.text.SpannableStringBuilder.delete(SpannableStringBuilder.java:33)
at android.view.inputmethod.BaseInputConnection.deleteSurroundingText(BaseInputConnection.java:249)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:398)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:82)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5538)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
done high bug

All 21 comments

I found the problem and I start working on it. The fix won't be shipped with 1.7.0 release. I guess we will provide 1.7.1 after a week or two.

ping @maknz

ping @lscown

Shouldn't 1.7.0 be held for this (assuming this is also causing the navigation issues). This is actually a fairly nasty issue and imho a blocking issue.

Good question. ping @valentinstoychev

I mean, this is probably as serious of an issue as they come. Our app is too unstable to ship in the current state. I understand the complexities around keeping the scope of the 1.7 release as-is and not introducing new things last minute. In reality, whatever is the quickest way to get the fix out, I'm on board with.

Hey guys,

We'd rather deliver the goodies we have accumulated already to the community. Fixing the management of the obect lifecycle is our current task. We hope to have 1.7.1 as soon as possible (estimated to some time early next week).

Thank you for your support!

Cheers,
Erjan

i have this bug every time.. costumer already complaining... really,... is there any temporarily work around?

FWIW, 1.7 improved things _dramatically_ for us. I think I saw one crash come through, but our app is basically back to normal after the 1.7 upgrade. Haven't played too much, but try that first if you haven't already.

The fix is in master branch. If you want to test it you can tryandroid@next package

tns platform remove android
tns platform add android@next

Hello, I got the same error, and already in nativescript 1.7.1, I think it got to do with memory management, what I tried to do is creating some kind of dropdown using listview, when the data is small, it works without error, but if the data is big (10000) when trying to search after typing (auto completion), sometime the error appears, it appears almost immediately in nexus 7 who has low memory and using genymotion it happened after few typings

Hope it can help

Hi @x4080

The fix is not included in 1.7.1. However you can try android@next which is built from master branch.

tns platform remove android
tns platform add android@next

Oh my mistake but when i tried tns platform add android@next shows error not found or something

And now add platform android@next is working dont know what did happened

I will try again

I think it works (in geniemotion) havent tried it on device, good job

hello @slavchev ,
i have try android@next on add platform not showing error, but if i run with tns run android show error :

platforms/android/build-tools/android-static-binding-generator/ast-parser/js_parser.js:192
                        enter(path) {
                             ^
SyntaxError: Unexpected token (
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
:asbg:runAstParser FAILED

Hi @Jayuda,
The error you have is because you have installed 0.10 or 0.12 version of nodejs. If you upgrade your nodejs to 4.x or 5.x, this problem will go away.

Tried on the device and it haven't crashed I think it is done

Same crash happens when you start camera module, take a photo with takePicture function, then you go back automatically to the same page from where you started your camera. And if on that page is a textField and you tap it, it's gonna crash with error 'no weak reference...'.

On 1.7.1 it shows excpetion on the screen and on 2.0.0 (master branch) it show "App crashed" dialog as on native android app.

@orsag Which version of android@next did you use? I pushed the fix two days ago with https://github.com/NativeScript/android-runtime/commit/5afd954a2acefb74f54d40f0fac2d949516a7d88. Also, is it possible to provide a small repro project?

I used android@next that was available about 10 days ago. I tested with current version 2.0.0-2016-04-27-549 and TextField works without crash.

Was this page helpful?
0 / 5 - 0 ratings