-
Notifications
You must be signed in to change notification settings - Fork 90
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
[Octane] animated-container throws "Cannot read property 'unlock' of null" #96
Comments
Hmm, our tests are green all the way out through canary as of last night, so this must have some specific preconditions to make it fail. Here are some notes on how the animate task is supposed to work, timing wise: animate: task(function * (duration, animationTask) {
this._startingUp = true;
let service = this.get('motionService');
let sprite;
let useMotion;
// During the first render, we don't yet have an element and this will return undefined
let element = this._ownElement();
if (element){
// This branch only happens on renders that are not the first render,
// when we already have an element in DOM before the animation begins.
sprite = Sprite.sizedStartingAt(element);
this.sprite = sprite;
sprite.lock();
useMotion = true;
} else {
// This branch happens on initial render, when there's no element in DOM
// at the start of animation.
useMotion = this.get('onInitialRender');
}
try {
// This is supposed to cause us to wait for ember to finish rendering.
yield afterRender();
// So from this point forward we expect that we necessarily must have an element.
yield microwait();
} finally {
this._startingUp = false;
}
yield * service.staticMeasurement(() => {
if (!sprite) {
// This branch covers the initial render case. Now that the initial render has
// happened, we can create our sprite.
sprite = Sprite.sizedEndingAt(this._ownElement());
this.sprite = sprite;
} else {
// This branch covers the non-initial render case. We already had a sprite, but need
// to measure its final bounds.
sprite.measureFinalBounds();
}
});
// Since the static measurement has finished, from this point forward we
// expect to always have this.sprite.
if (useMotion) {
yield* new (this.motion || Resize)(this.sprite, { duration })._run();
}
yield animationTask;
this.sprite.unlock();
this.sprite = null;
}).restartable() |
Thank you, that was quite helpful. I continued digging into this and have found that the "real error" (the first one that then causes another one to barf) is in https://github.com/ember-animation/ember-animated/blob/d7ee355a09/addon/-private/sprite.js#L568 This is called from The problem is that inside Sprite, I wonder what I'm doing wrong/differently that ember-animated sets out to measure a text node (which I guess it shouldn't). The template snippet I use is above, in my original description. |
Turns out what caused this is that there was an https://github.com/ember-animation/ember-animated/blob/d7ee355a09/addon/-private/ember-internals.js Here is the snippet: <AnimatedContainer class="flex flex-row flex-wrap">
{{#animated-each this.sortedPlayers key="id" use=transition as |player|}}
{{#link-to
"player"
player.id
class="no-underline text-blue hover:text-blue-darker w-350px"
}}
<PlayerCard @player={{player}} />
{{/link-to}}
{{/animated-each}}
</AnimatedContainer> Consequently, #97 fixed this for me. I'm not completely sure if that's a solid fix but it seems reasonable that we don't want text nodes inside an AnimatedContainer and #97 takes care of one such case. I guess we should also take care (as in, tell people) that they shouldn't put pure text nodes inside |
This also works with the latest octane blueprint, so I'm closing. |
After upgrading to Octane, I got an
Cannot read property 'unlock' of null
, thrown by this line:https://github.com/ember-animation/ember-animated/blob/master/addon/components/animated-container.js#L166
I put a breakpoint there and have found that
this.sprite
is not set to the correct sprite becausethis._ownElement
returns null:https://github.com/ember-animation/ember-animated/blob/master/addon/components/animated-container.js#L133-L142
So
this.sprite
remains its initial value, null.That, in turn, is because
this._ownElement
is only set ifthis._inserted
is set to true and that happens in thedidInsertElement
hook which is called after we get to the line that callsthis.sprite.unlock()
.The code I have is as follows:
Not sure how this is related to Octane but this has worked in the non-Octane version, in 0.5.1 of ember-animated.
The text was updated successfully, but these errors were encountered: