Skip to content
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

refactor(ivy): remove TStylingContext locking in favor of firstUpdatePass flag #33521

Closed
wants to merge 4 commits into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Oct 31, 2019

This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the tNode.firstUpdatePass is used to track when bindings are
registered on the context instances.

@matsko matsko added target: major This PR is targeted for the next major release comp: ivy labels Oct 31, 2019
@ngbot ngbot bot modified the milestone: needsTriage Oct 31, 2019
@AndrewKushnir AndrewKushnir added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Oct 31, 2019
@matsko matsko force-pushed the first_update_pass_styling_new branch 3 times, most recently from 695a0b2 to a2527ec Compare November 4, 2019 21:44
@matsko matsko marked this pull request as ready for review November 4, 2019 21:45
@matsko matsko requested a review from a team as a code owner November 4, 2019 21:45
@matsko matsko requested review from kara and mhevery November 4, 2019 21:45
@matsko matsko force-pushed the first_update_pass_styling_new branch from a2527ec to 7c18290 Compare November 4, 2019 22:14
@matsko matsko requested a review from a team as a code owner November 4, 2019 22:14
@matsko
Copy link
Contributor Author

matsko commented Nov 5, 2019

@@ -93,8 +92,8 @@ export function allowDirectStyling(context: TStylingContext, hostBindingsMode: b
// `ngDevMode` is required to be checked here because tests/debugging rely on the context being
// populated. If things are in production mode then there is no need to build a context
// therefore the direct apply can be allowed (even on the first update).
allow = ngDevMode ? contextIsLocked : true;
} else if (contextIsLocked) {
allow = ngDevMode ? !firstUpdatePass : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line and comment looks suspicious. It seems to me that we are changing runtime behavior depending on the ngDevMode? That does not seem right to me. Can you better explain to me what is going on?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to populate a context whilst in prod mode. The only only reason we do this is in devMode is so that debugNode.styles.debug and debugNode.classes.debug can properly list out all classes/styles on the element (otherwise it doesn't know because the direct styling apply mode doesn't keep track of anything).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this not imply that we could accidentally rely on that information in ngDevMode??? I think it would be better if we did not have such code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix for this is to design a debugging layer that works independent of the underling style/class application algorithms.

* provided `TStylingContext` (which is an instance of a `StylingMapArray`). This inner map will
* be updated each time a host binding applies its static styling values (via `elementHostAttrs`)
* so these values are only read at this point because this is the very last point before the
* first style/class values are flushed to the element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is confusing. Could we have a small code snippet / Concrete example showing why this is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@matsko matsko force-pushed the first_update_pass_styling_new branch from 7c18290 to 53ecac9 Compare November 5, 2019 06:07
Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

packages/core/src/render3/styling/bindings.ts Outdated Show resolved Hide resolved
packages/core/src/render3/styling/bindings.ts Show resolved Hide resolved
packages/core/src/render3/instructions/styling.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/styling.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/styling.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/styling.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions/styling.ts Outdated Show resolved Hide resolved
@matsko matsko force-pushed the first_update_pass_styling_new branch 2 times, most recently from 03f6b01 to 1a51126 Compare November 5, 2019 22:15
Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take care of @kara comments

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matsko matsko added the action: merge The PR is ready for merge by the caretaker label Nov 5, 2019
@ngbot
Copy link

ngbot bot commented Nov 5, 2019

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "ci/circleci: material-unit-tests" is failing
    pending status "ci/circleci: setup" is pending
    pending status "google3" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@matsko matsko force-pushed the first_update_pass_styling_new branch from 1a51126 to 6f78c1c Compare November 5, 2019 22:43
…Pass flag

This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the `tNode.firstUpdatePass` is used to track when bindings are
registered on the context instances.
@matsko matsko force-pushed the first_update_pass_styling_new branch from 6f78c1c to 9be823a Compare November 5, 2019 23:10
@matsko
Copy link
Contributor Author

matsko commented Nov 5, 2019

@atscott atscott closed this in 3297a76 Nov 6, 2019
atscott pushed a commit that referenced this pull request Nov 6, 2019
…Pass flag (#33521)

This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the `tNode.firstUpdatePass` is used to track when bindings are
registered on the context instances.

PR Close #33521
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…Pass flag (angular#33521)

This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the `tNode.firstUpdatePass` is used to track when bindings are
registered on the context instances.

PR Close angular#33521
mohaxspb pushed a commit to mohaxspb/angular that referenced this pull request Nov 7, 2019
…Pass flag (angular#33521)

This patch removes the need to lock the style and class context
instances to track when bindings can be added. What happens now is
that the `tNode.firstUpdatePass` is used to track when bindings are
registered on the context instances.

PR Close angular#33521
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants