jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Improve angular performance

Open lucas-koehler opened this issue 3 years ago • 1 comments

Calculate Angular layout renderer child props via a pure pipe

Increase rendering and on change performance for all forms including nultiple layouts:

  • Avoid unnecessary recalculation of the child render props.
  • In turn, avoid some unnecessary change detection cycles in children.

Add service method to get global config

When querying the state from the JsonFormsAngularService via its getState method, the whole state is cloned. This lead to a heavy performance penalty because the JsonFormsAbstractControl queried the state on every change detection cycle to get the global config. Thus, the whole state was cloned for every control on every change. As the config is only a small part of the state, this problem can be alleviated by adding a getConfig method to the service that only clones the config.

  • Extend JsonFormsAngularService with a getConfig method that returns a clone of the global config
  • Use the new method in JsonFormsAbstractControl

Add service method to get locale

When querying the state from the JsonFormsAngularService via its getState method, the whole state is cloned. This could lead to performance issues with the angular material renderer set because the NumberControlRenderer queried the state on every change detection cycle to get the locale. Thus, the whole state was cloned for every control of these types on every change. To fix this, the JsonFormsAngularService now allows to query the locale directly without cloning the state

  • Add method getLocale to JsonFormsAngularService that does not clone the state
  • Use new method in NumberControlRenderer

Fix #1946

lucas-koehler avatar Sep 08 '22 14:09 lucas-koehler

Coverage Status

Coverage increased (+0.1%) to 84.451% when pulling 867789c33030db2e9258044e21bb7151588fb1a9 on angular-performance-improvements into 79e1c56d17dff9c3874256e2c096585b12a9e8a7 on master.

coveralls avatar Sep 08 '22 15:09 coveralls

Please can we get this reviewed by an approver? The angular component at the moment is very slow and laggy when we have more than a dozen components.

FredUK avatar Oct 24 '22 12:10 FredUK

Hi @FredUK, yes will review soonish and if there are no issues this will be part of the next (pre)release.

sdirix avatar Oct 24 '22 12:10 sdirix