-
-
Notifications
You must be signed in to change notification settings - Fork 241
TypeError: Cannot read property 'destroyed' of null #1221
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
Comments
hii @tsonevn , |
hi @tsonevn , |
Hi, @bhavincb, Regarding that, could you replace WebImage with the Image component provided by NativeScript core modules and check if the issue is related to the plugin's component. After replacing the WebImage, remove the platform with |
hii @tsonevn ,
in above code albumObj is shared service which has "albums" named array. this service initially fetch previous Albums from the local database. and also request fro new albums data and updates it. i had getting error i had mentioned in previous comment.
above function was real culprit. if i remove the So in conclusion i can say that when using |
We're having the same issue. As soon as we hook a "loaded" listener, all hell breaks loose. We're using a directive to add some attributes to a TextField on Android, no change detection at all. Even just binding a If we use a single Label inside the for and set I can set up a playground if needed. |
Hi @edusperoni, |
I'd also like to add that this issue also happens using RadListView, but it's actually a little worse. We have recently started using RadListView with this template:
and we use (loaded) inside this component. As soon as we changed from ListView to RadListView, it complained about not being able to read "details" of undefined and PullToRefresh stopped working for some reason. Adding a Are there any updates on this issue? |
HI @edusperoni, |
I am also having same problem with ngx-pagination, while there is data available it works fine, if there is no data(null) then its replicating pagination page numbers. |
I'd like to provide more info about this issue, in hopes it gets into the next release. As you may have seen, I've commented on #848 (comment) saying it's basically impossible to get the android view as it loads due to both these bugs. After some testing, I've arrived to the conclusion it's the angular event binding specifically that causes this bug. I've updated my example to exemplify it: https://play.nativescript.org/?template=play-ng&id=hpl6OJ&v=4 If you use (loaded) and (unloaded), you get:
and ultimately a crash:
but if you use my directive which adds safeLoaded and safeUnloaded. You get no error at all, and that's done with If you start listening to the event on the directive constructor (set ensureItemExists = false), before the element is loaded, you still get
But no If you do it in ngAfterViewInit (set ensureItemExists = true), you sometimes have to manually trigger a loaded event in case the element hasn't loaded (this happens sometimes in android, as seen in #848), but once that is done, you get the item AND no crash/errors. Maybe this is enough to shed some light on the issue? |
Hi all, |
I can confirm layoutChanged doesn't trigger the error. So far, it only seems to happen on Added layoutchanged to example: https://play.nativescript.org/?template=play-ng&id=hpl6OJ&v=5 |
Ok, I found why this error occurs. Wrapping the callback in NgZone.run breaks the code. See: https://play.nativescript.org/?template=play-ng&id=hpl6OJ&v=6
this is the same logic being used in nativescript-angular renderer
It seems ngzone tries to check if the element is destroyed, but at the time of loading and unloading, it's null, so it throws the error. Edit: More testing. Using a setTimeout 0 to make it run on the next angular cycle also fixes the problem:
AND the item is available on load. Forcing a change detection with Some things seem to be happening out of order, so when we try to enter Angular's zone, not everything is ready yet, so it breaks. Test project with setTimeout: https://play.nativescript.org/?template=play-ng&id=hpl6OJ&v=7 Edit 2: After giving it some more thought, it seems the loaded event is called just after So our options probably are either making these events run outside of angular, and it's up to the developer to use timeouts, or setting the timeout inside the listen which means the event won't be called in the exact moment it happens (already true for loaded, anyway). |
May be following can help https://stackoverflow.com/a/46407516/9297920 |
After over 1 year of thinking about this on and off I FINALLY found the solution, and the problem is way deeper than I originally thought. The problem is specifically with
This happens for 2 reasons:
This discovery raises some issues:
I'll write a PR wrapping all |
This comment was marked as abuse.
This comment was marked as abuse.
@NathanaelA While writing the PR and tests, the problem seems to be with If you trigger
Angular has an "NgZone" which contains an inner zone (actual angular zone) and outer zone (code running without angular "knowning"). The code from
which means if a request came from the angular zone, Now for some reason, this bug only happens when you have other tasks queued up (which is often the case in real apps), so it can't be reproduced in unit testing, which probably means the issue is not with running the code inside the angular zone, but something with zone itself. My solution of running it inside the ngzone is actually more of a workaround. On all cases, |
if we use above code then app is starting without any errors and output is as expected.
but using below code i get the error that "ERROR TypeError: Cannot read property 'images' of null "
we can clearly state that both code are equivalent and should give similar output.
but last gives error "ERROR TypeError: Cannot read property 'images' of null"
Detailed error is like this:
i had also tried binding label text to function in which local album variable gets printed like below
<Label [text]="conDir(group)" class=" list-group-item-heading"></Label>
conDir(a){ console.log(a.id) console.log(a.name) return a.name; }
Looking at logs i can verify that "album" is not null and has correct value as it should have.
so i have no idea what can be wrong.
The text was updated successfully, but these errors were encountered: