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

fix(core): Allow modification of lifecycle hooks any time before bootstrap #38119

Closed
wants to merge 1 commit into from

Conversation

mhevery
Copy link
Contributor

@mhevery mhevery commented Jul 17, 2020

Rebase of #45464 onto 10.0.x


PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@mhevery mhevery added area: core Issues related to the framework runtime action: merge The PR is ready for merge by the caretaker PR target: patch-only and removed cla: yes labels Jul 17, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jul 17, 2020
@ngbot
Copy link

ngbot bot commented Jul 17, 2020

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "pullapprove" is failing
    pending missing required labels: cla: yes
    pending status "ci/circleci: setup" is pending
    pending status "google3" is pending
    pending missing required status "ci/circleci: build"
    pending missing required status "ci/circleci: lint"
    pending missing required status "ci/circleci: publish_snapshot"
    pending missing required status "ci/angular: size"
    pending 5 pending code reviews

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.

@AndrewKushnir AndrewKushnir added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jul 17, 2020
…strap

Currently we read lifecycle hooks eagerly during `ɵɵdefineComponent`.
The result is that it is not possible to do any sort of meta-programing
such as mixins or adding lifecycle hooks using custom decorators since
any such code executes after `ɵɵdefineComponent` has extracted the
lifecycle hooks from the prototype. Additionally the behavior is
inconsistent between AOT and JIT mode. In JIT mode overriding lifecycle
hooks is possible because the whole `ɵɵdefineComponent` is placed in
getter which is executed lazily. This is because JIT mode must compile a
template which can be specified as `templateURL` and those we are
waiting for its resolution.

- `+` `ɵɵdefineComponent` becomes smaller as it no longer needs to copy
  lifecycle hooks from prototype to `ComponentDef`
- `-` `ɵɵNgOnChangesFeature` feature is now always included with the
  codebase as it is no longer tree shakable.

Previously we have read lifecycle hooks from prototype in the
`ɵɵdefineComponent` so that lifecycle hook access would be monomorphic.
This decision was made before we had `T*` data structures. By not
reading the lifecycle hooks we are moving the megamorhic read form
`ɵɵdefineComponent` to instructions. However, the reads happen on
`firstTemplatePass` only and are subsequently cached in the `T*` data
structures. The result is that the overall performance should be same
(or slightly better as the intermediate `ComponentDef` has been
removed.)

- [ ] Remove `ɵɵNgOnChangesFeature` from compiler. (It will no longer
      be a feature.)
- [ ] Discuss the future of `Features` as they hinder meta-programing.

Fix angular#30497
@AndrewKushnir AndrewKushnir removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Jul 17, 2020
@AndrewKushnir
Copy link
Contributor

FYI, this is patch-only version of the PR #35464 that was reviewed and approved, so no additional reviews are required.

AndrewKushnir pushed a commit that referenced this pull request Jul 17, 2020
…strap (#38119)

Currently we read lifecycle hooks eagerly during `ɵɵdefineComponent`.
The result is that it is not possible to do any sort of meta-programing
such as mixins or adding lifecycle hooks using custom decorators since
any such code executes after `ɵɵdefineComponent` has extracted the
lifecycle hooks from the prototype. Additionally the behavior is
inconsistent between AOT and JIT mode. In JIT mode overriding lifecycle
hooks is possible because the whole `ɵɵdefineComponent` is placed in
getter which is executed lazily. This is because JIT mode must compile a
template which can be specified as `templateURL` and those we are
waiting for its resolution.

- `+` `ɵɵdefineComponent` becomes smaller as it no longer needs to copy
  lifecycle hooks from prototype to `ComponentDef`
- `-` `ɵɵNgOnChangesFeature` feature is now always included with the
  codebase as it is no longer tree shakable.

Previously we have read lifecycle hooks from prototype in the
`ɵɵdefineComponent` so that lifecycle hook access would be monomorphic.
This decision was made before we had `T*` data structures. By not
reading the lifecycle hooks we are moving the megamorhic read form
`ɵɵdefineComponent` to instructions. However, the reads happen on
`firstTemplatePass` only and are subsequently cached in the `T*` data
structures. The result is that the overall performance should be same
(or slightly better as the intermediate `ComponentDef` has been
removed.)

- [ ] Remove `ɵɵNgOnChangesFeature` from compiler. (It will no longer
      be a feature.)
- [ ] Discuss the future of `Features` as they hinder meta-programing.

Fix #30497

PR Close #38119
@ramtob
Copy link

ramtob commented Jul 20, 2020

@mhevery
Thanks very much for this fix.
Will it be added to version 9.x also?

@mikaelboff
Copy link

We need this o 9.x too, it'll be done too? @AndrewKushnir @mhevery

@mlc-mlapis
Copy link
Contributor

mlc-mlapis commented Jul 20, 2020

I think that it's necessary to count on the fact that it won't be added to any previous versions. As usual, new features flow only forward. Where is the problem with such logic? The difference between 9 and 10 is not so significant so it's easy to migrate.

@mikaelboff
Copy link

makes sense @mlc-mlapis

@ramtob
Copy link

ramtob commented Jul 21, 2020

I think that it's necessary to count on the fact that it won't be added to any previous versions. As usual, new features flow only forward. Where is the problem with such logic? The difference between 9 and 10 is not so significant so it's easy to migrate.

It happens that I am partly dependent on applications that do not make upgrades often. So waiting for them to upgrade to version 10 might take months. Not that I am asking for personal favors :) I thought it was due naturally to enter version 9, since the issue was opened when Angular was at version 9. Angular switched to version 10 when the PR was still in process.

@ramtob
Copy link

ramtob commented Jul 21, 2020

P.S. and what is this "patch" for anyway? Why is there a PR for a "patch" beside the original PR? I thought it was related too to fixing previous versions.

@petebacondarwin
Copy link
Member

"Patch" is the version branch that is currently receiving bug fixes. Currently this is 10.0.x.
"Master" is the version currently receiving active development, which will result in 10.1.0.

@ramtob
Copy link

ramtob commented Jul 21, 2020

"Patch" is the version branch that is currently receiving bug fixes. Currently this is 10.0.x.
"Master" is the version currently receiving active development, which will result in 10.1.0.

Thanks. Which reminds me: this PR is a fix, not a feature. Which also seems to provide a reason for applying it to version 9 too..

@petebacondarwin
Copy link
Member

petebacondarwin commented Jul 21, 2020

Yes, patch (10.0.x) receives only bug fixes, not features; master receives features, which will end up in 10.1.0.

@mlc-mlapis
Copy link
Contributor

mlc-mlapis commented Jul 21, 2020

@ramtob It certainly would be fine to have it also in 9.x, but it would also mean significant circumstances and additional costs. Just imagine how standard development flow is going on. It starts at some point. All surrounding things are changing from day to day, even new versions and so. You, as a developer, are keeping your work up-to-date with all the latest changes, continuously merging, so in the end, you finish your work in a different situation than you have been started.

@BryanYin
Copy link

BryanYin commented Aug 3, 2020

This bug is critical, all reasons listed in the original issue. So it should be ported to v9, as per stated below:

All of our major releases are supported for 18 months.

6 months of active support, during which regularly-scheduled updates and patches are released.
12 months of long-term support (LTS), during which only critical fixes and security patches are released.

VERSION STATUS RELEASED ACTIVE ENDS LTS ENDS
^10.0.0 Active Jun 24, 2020 Dec 24, 2020 Dec 24, 2021
^9.0.0 Active Feb 06, 2020 Aug 06, 2020 Aug 06, 2021
^8.0.0 LTS May 28, 2019 Nov 28, 2019 Nov 28, 2020

@bryanrideshark
Copy link

If you started using 9.x and then realized this bug, you obviously have learned how to live with it, or you've downgraded to Angular 8.

Upgrading to Angular 10 may be an issue to people because of policies, but you've already made compromises if you're using Angular 9 with this bug. I don't think we should demand the team backport this rather extensive PR just to satisfy our policies.

@mikaelboff
Copy link

any updates?

@mlc-mlapis
Copy link
Contributor

@mikaelboff Update for what?

@mikaelboff
Copy link

didn't saw it was released, thanks @mlc-mlapis

@mhevery
Copy link
Contributor Author

mhevery commented Aug 10, 2020

We need this o 9.x too, it'll be done too? @AndrewKushnir @mhevery

Sorry, this will not be added to v9. If you need this functionality please upgrade to latest code.

@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 Sep 10, 2020
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 area: core Issues related to the framework runtime cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants