-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Fixes #4826] detach ManyPromiseProxies when a new one is created #4827
Conversation
Am I right in thinking it's the proxy that's sent out to the outside world? If so keeping it stable would be better - I could pass it off to something else (e.g. a service) which wouldn't expect it to be destroyed later |
@BryanCrotaz yup you are correct, I am planning to take the stable proxy route. Tou can use this code today, and it will be better then the existing. But before merging, stable proxy stuff will need to be added. |
I don't think you can turn today's proxy into a stable object. You'd need to replace the promise and the content. From the docs...
What are your thoughts thus far? |
Still the same. I believe we need a stable promise proxy here. The assertion you mentioned is in-fact what happens today, but as the person who added that assertion I feel empowered to consider changing it, or making a mutable variant. I will most likely make a mutable variant for ember-data, experiment with it, and see where it goes. If you have time to spike a mutable variant for experimentation, that would be great... |
My thinking was around what happens if the original promise has not settled, but you're swapping out the promise. You can't cancel the original promise, or detach the |
There should be no difference in the success case, as the Which at best seems fine, and at worst seems cost of doing business. Thoughts? |
what if the old and new promise complete out of order? won't you get the wrong content? |
@BryanCrotaz I believe behavior we have today would remain the same, only improved. As for the promiseProxy thanks for pointing out the ordering concern, I'll make sure the order remains reasonable, and should likely mimic what one would experience today (or improve) but with proxy stability. Not based on the order the promises landed but the ordered the promises where associated with the proxy. (this would prevent out of order) I suspect this effort wont just fix the memory leaks, but also improve performance. In the example you provided, I notice there was more rendering churn happening then expected. I suspect it is related to this above mentioned instability. |
I also want to do some more work around optimising notifications. ArrayObservers are not well served by Ember Data. The current code just clears the array and then repopulates it. I have an old branch that makes some big improvements but it's never been merged and now is so badly diverged that I can't work out how to merge it. |
This work could be extended by refactoring computed macro filters to use array observers - no need to check the filter on an array member if it wasn't just added. |
In my example we really shouldn't have any rendering at all - nothing changed in the data. |
@AndyPyeSC (on my team) says the promise proxy is already reusable (though we haven't tested replacing a promise that isn't yet settled), so we'll have a go at utilising that in HasMany |
To follow up on the comment @BryanCrotaz made above, the promise proxy mixin seems to handle very simple "linear" timelines of promise update and fulfillment as it stands. However, the case of the promise being updated before it resolves/rejects isn't handled as I'd expect it to be. We'd also need to figure out what the state ( |
For my money once the state If it I'm suggesting to Andy that we start by implementing everything other than replacing the promise while the current one is not yet settled. That will fix the memory leak and only leaves the race condition to be fixed. |
My initial though tis that it should update and reflect those attributes based on the current state. |
superseded by #4842 |
WIP:
An alternative path would be to keep the proxy stable as well, and just mutate it..