-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
[Marking Mode: None]: Crash: Attempt to use cleared object reference #887
Comments
Hi @daveware-nv, we're going to be able to better assist you if you provide steps to reproduce, with the minimal code required or a small repo for us to check out. |
As mentioned I don't know when it occurs as I haven't observed it myself, nor as a result do I know what the minimal code required to reproduce would be. snippets from the package.json:
notes:
Is there some detailed documentation on what 'taken care of by the developer' means in you above post? The only reference I've seen to We have a lot of data going into and out of couchbase, so depending on what care needs to be taken with which kinds of java objects that may be the first place for me to look once I know what to look for. |
The simplest way for me to explain what to look for. Consider this scenario in your code or in some native plugin you're using (there's a big chance the problem is in the plugin, as the currently available plugins aren't meant to be used in conjunction with problem
The solution
summary
needs to be managed by the developer. You should decide when it should be not used anymore and can be let go for GC. |
We haven't got a blog post about it because it's an experimental flag, and we're still contemplating on trying it out. We wanted to check out what kinds of problems developers would encounter, so we get a better understanding of the user scenarios. |
Thanks. If that is the extent of it, then it should be less of a problem to track things down in my code than I expected. Less easy are Unfortunately |
@daveware-nv, did you manage to fix your issue or are you still trying to figure out where the problem is? |
Unfortunately I haven't had time to complete my sweep yet. And I probably wont know for sure whether any changes made fixed everything until we make another release, since the crashing hasn't really shown up during test usage. I have established some candidates to clean up however:
And of course then there is |
Both plugins are usable with the current version of the android runtime, but they are not compatible with
It doesn't really matter if the javascript objects with the native counterparts are passed as a parameter or not, except for their life duration. Unfortunately, the error you saw, will be the same no matter if the parameters are passed as arguments to a function or not. |
That is unfortunate, that probably makes my efforts (and yours) here moot for the time being. So I'll probably have to advise the project owner that
I was mostly implying that since they are passed as parameters there must be a reference to them somewhere else (not just the method where I'm defining my interface implementation) on the stack, and hence where responsibility for managing the references to the native object are. The other thing I was asking was whether pure javascript objects can also get GC'd early across this boundary? |
We've not settled on using
Pure js objects are dealt with entirely by V8's GC. If V8 decides it's time to GC an object, it does usually because it can't reach it in the object graph. I haven't seen cases where the pure js object is being collected early, thus causing errors. This happens only for js objects that have native counterparts like |
I am getting a similar error on random occasions. Setup:
Error:
|
Hi @yyankov thank you for your feedback. When I look at the error you posted, I can point you in the right direction: |
Closing due to lack of activity. |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA That's incorrect. When marking mode is set, it changes the way GC works, so any related GC issues will be completely different.
It's really unfortunate that you found the problem in
I closed the issue, just as I said "because of the lack in activity". We'd be happy to reopen it, should the need occur. For now it hasn't, because there's no new development on our side, nor on the current issue. @NathanaelA If you figured out, something we haven't please share your knowledge or better yet do a PR, as you're knowledgeable enough to provide assistance to the plugin authors. |
This comment was marked as abuse.
This comment was marked as abuse.
I'm reopening the issue as the problem is real and is not resolved. Our plans for after the 4.0 release are to focus on making plugins maintained by NativeScript compatible with markingMode: none. Cases like this one will be useful for us to validate whether we have covered all cases. |
Now that it's post 4.0, it would be really great news if you were working on the markingMode changes for the plug-ins. NS is an excellent system, well designed and with a great developer experience. Unfortunately the current choice between slowness (markingMode not set) and crashes (markingMode set to none) makes it difficult to ship on Android. |
Indeed, this is one of the things we will focus on for 4.1. |
Hi everybody, There is a class of "Attempt to use cleared object reference" errors that is thrown out there, here is some insight on the design of
This means that when So any error that happen, related with the Java instance being prematurely collected, should be due to JavaScript trying to call to Java. For example if you call method on an object, and that object was already collected, you should get a JavaScript callstack, and fixing errors having this callstack should be easy. On the other hand the error report for failed methods seem fine (you have JavaScript stack) but the:
kind of errors are total no-go. The {N} Android team should probably figure out where these Figure out this getJavaObjectByID is only used from C++: And that's why the Java callstack above seems lacking enough information. The cache is initialized with this, and this cache on the other hand is used only in the ObjectManager GetJavaObjectByID: Which is then used by
https://github.com/NativeScript/android-runtime/search?q=GetJavaObjectByJsObject&type=Code
Every single place where it is used, we have isolate that is available and a JavaScript callstack should be available somewhere there, but the generated NativeScriptException seems to hide it. With that said (if you choose to proceed with markingMode: none), the android runtime will have to do some advancements in the error reporting here. Since the errors will be random and hard to reproduce the error messages should be enough to locate and fix potential problems. These errors should be collectible by error reporting services (android crash reports? firebase?). Only when this is done we will be able to provide the "how to fix". |
The full log has javascript traces: |
Sorry for the delay I was absent for a few weeks. I have an update how the issue was solved on my end. I upgraded native script/angular/ts to the latest ones as describe in here: https://docs.nativescript.org/releases/upgrade-instructions and the issue was magically solved. Now instead of app breaking and "attempt to use cleared object reference" exceptions I am receiving different exceptions very benign ones: JS: Error in downloadBitmap - java.io.InterruptedIOException: thread interrupted |
I has the same error message:
My package.json: My app has a List which contains posts, post will have image. So when scroll down and up quickly, this error will show. |
You can try with android@next if you can easily reproduce the error to see whether the pull request above fixes it. |
Old issue. I though that the issue has gone after moving to NS 5.3. But it just occurs less oftеn. Unhandled Promise rejection: com.tns.NativeScriptException: Attempt to use cleared object reference id=1511 |
@valera1401 It should be fixed in 5.4, so for now use android@next |
@jpierront I already use android@next |
@jpierront Please notice that before NS 5.3 this exception occurred after short period of time after the app launch (2-3 minutes). Now it occurs after longer period, maybe after 15 minutes of the app working. |
This comment was marked as abuse.
This comment was marked as abuse.
The table will not become too large as it has to keep trace of what is the JavaScript class and where it is declared for a Java instance. So when the JS instance is collected you have to write up in the table debug information for the Java instance. That information can be stored in weak dictionary for example that will be cleared when the Java instance is collected. |
This comment was marked as abuse.
This comment was marked as abuse.
When Java is calling a method and a reference is passed that... the Java instance has been collected? That throws null reference exception, right? It will not try to marshal it to its JavaScript instance. But I agree that we need very good error reporting. When these errors occurs we often have the Java instance and can provide information from it as well as full stack trace sandwich and if possible the JS class source... |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA gentle reminder, in case you've had a chance to look at this. |
@NathanaelA I would also love to see this resolved since NS is so awesome! |
@NathanaelA error still exists. |
@ivandejesus See NativeScript/NativeScript#7867 for a possibly working hack if you are in this case :) |
I am facing this issue too.. |
I'm facing the same issue too - any news on fix or workaround? |
I had to remove marking Mode: None and until I did this I haven't seen this exception. Someone mentioned about plugins which don't support marking mode: none. |
I fear the issue is NOT related to Plug-in only. |
In generall apllication performance is pooor even though application is really simple. I didn't notice difference with and without marking mode. This is Angular based one. |
I've given up on nativescript and tamers to flutter. It seems to be gaining speed and has plenty of useful plugins. Plus it comes with a lot more features out of the box. On 26 Jan 2020 16:46, kokosky93 <notifications@github.com> wrote:In generall apllication performance is pooor even though application is really simple. I didn't notice difference with and without marking mode.
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
|
I'm evaluating FLUTTER too, I agree it looks very promising - furthermore, now NS Plugins require subscription :( |
This comment was marked as abuse.
This comment was marked as abuse.
I've fairly new to mobile development. And at first nativescript has been pretty great. Use of html and css can be both a benefit and a hindrance. But when this crash has started reoccurring as the client data increased, it was a no go (still fairly modest collection). I had to ditch nativescript after this bug ticket had been open for such a long time. After all this goes back a couple of years or so. On 27 Jan 2020 03:25, Nathanael Anderson <notifications@github.com> wrote:@gkoulin @ematechno - Just a FYI; I have actually done some Flutter apps (after all I am a contractor -- I do work in almost every language if you pay me. 😀 ) You have a lot of serious & signifincant gotchas/bugs with it. I honestly would not put any client apps in most areas I do apps on Flutter at this point. There are a couple areas that Flutter would be great for, but the majority; you are just wasting your time, as your clients will be ticked at your delivered frequently crashing app... Forewarned is forearmed. It has wonderfully awesome tooling, and I love the developer experience with Flutter; but the apps it creates, you will run into weird compatibility issues in several areas than with NativeScript/ReactNaitve or even just plain Native. Awesome concept; lousy compatibility and some of these significant bugs reports have been open forever. :(
As for ProPlugins -- you are correct, I started the subscription service -- it, imho, was the only way to guarantee high quality plugins would continue on NativeScript. Too many open source authors were facing burn out and no one was picking up the pieces. I know for myself, I would have stopped maintaining most my plugins as the costs to my family were too high. But ProPlugins actually helps financially support some of the time spent on the plugins, and as such it has allowed me to do probably 30+ updates across all my plugins without the cost to my family being horrible. The crazy thing is, no one thinks about how much they are getting paid per hour to make an application, but they complain about what costs them probably only 1-5 hours of their time per year, if their company can afford to pay them 30k - 100k, The subscription is crazy cheap for all the development work that they don't have to do now... 😀
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.
|
This comment was marked as abuse.
This comment was marked as abuse.
Great... !!! I also encountered this kind of bug using one image inside each item of a RADListView while scrolling fast up or down... Is there a way of handling image differently to avoid this kind of error ? Or just don't use RadListView anymore ? Thanks for help. |
@lostation provide a demo application that reproduces the issue so we could investigate further. Simply using a RadListView with a lot of images is not reproducing the issue on my side - are you sure you are not using other elements/layouts/plugins inside the item templates? |
Hi,
Thanks for your reply.
No unfortunately, I’m not authorized to put a demo example.
But really it’s nothing fancy at all… it’s a regular RadListView as described into Nativescript docs for Angular.
I’ve just added a <Image> tag into the list item into a GridLayout, there’s no external plugin or whatever.
If I remove the image it works just fine…so it’s clearly linked to a nullable element at mobile platform side.
If I turn markingMode to full it also not crash anymore…but indeed poor performance after some times.
I’ve also tried using a simple ListView component (not radlist)… but it’s the same scroll behavior behind…If a scroll too fast..then randomly it will crash the app.
BUT,… If a put a simple Gridlayout as a wrapper around the Image tag with a *ngIf directive to verify if src can be fulfilled it seems to not crash anymore.
So If no src data … no Image element into the template and no link to android glide or Picasso adapter or something.
I will continue with that fix…and let you know If I get other JNI crash from android.
Thanks anyway.
Lo.
… Le 17 févr. 2020 à 10:39, Nick Iliev ***@***.***> a écrit :
@lostation <https://github.com/lostation> provide a demo application that reproduces the issue so we could investigate further. Simply using a RadListView with a lot of images is not reproducing the issue on my side - are you sure you are not using other elements/layouts/plugins inside the item templates?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#887>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACX5G6WUZJN5DTPV5HX4WE3RDJLMZANCNFSM4EFXU3VA>.
|
Please, provide the details below:
Via crashlytics we have been getting reports of crashes of the type
com.tns.NativeScriptException: Attempt to use cleared object reference id=48048(com.tns.NativeScriptException: Attempt to use cleared object reference id=48048 com.tns.Runtime.getJavaObjectByID(Runtime.java:893)
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Other closed bugs reference the same or similar issues (latest was closed for 3.0.0).
Please provide the following version numbers that your issue occurs with:
Built using webpack (
npm run ns-bundle --android --build-app --snapshot --clean --release
)Also using in
app/package.json
:Did the error happen while the app was being constructed? (buildtime error)
No
Did the error happen while the app was executing? (runtime error)
Yes, but I haven't reproduced it myself. Just numerous similar stack traces being sent via crashlytics/fabric.
e.g.
full trace at https://pastebin.com/JEGTYrpx
Please tell us how to recreate the issue in as much detail as possible.
Unknown. Possibly random.
The text was updated successfully, but these errors were encountered: