Skip to content

perf: faster view layout handling#8255

Open
farfromrefug wants to merge 28 commits into
NativeScript:release/8.0.0from
Akylas:layout_improvements
Open

perf: faster view layout handling#8255
farfromrefug wants to merge 28 commits into
NativeScript:release/8.0.0from
Akylas:layout_improvements

Conversation

@farfromrefug
Copy link
Copy Markdown
Collaborator

reponed #7996 as draft

Related to this issue #7988

For now this PR only checks for auto in width or height. This is clearly not enough.
But the idea is to check if it is necessary to requestLayout on the parent. Most of the times it is not necessary.

In the case of a complex app the improvements is huge!. It makes apps using animations (not using {N} animation system which is too limited) far more snappier.

This is only a POC!

farfromrefug and others added 16 commits July 25, 2018 10:59
For now this PR only checks for auto in width or height. This is clearly not enough.
But the idea is to check if it is necessary to requestLayout on the parent. Most of the times it is not necessary.

In the case of a complex app the improvements is huge!. It makes apps using animations (not using {N} animation system which is too limited) far more snappier.

This is only a POC!
…mprovements

# Conflicts:
#	tns-core-modules/ui/core/view/view.android.ts
#	tns-core-modules/ui/gestures/gestures.ios.ts
@cla-bot cla-bot Bot added the cla: yes label Jan 17, 2020
}

public requestLayout(): void {
public requestLayout(calledFromChild?:boolean): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space is needed after the colon in parameter to match the tslint rules

Suggested change
public requestLayout(calledFromChild?:boolean): void {
public requestLayout(calledFromChild?: boolean): void {

super.requestLayout();
if (this.nativeViewProtected) {
this.nativeViewProtected.requestLayout();
public requestLayout(calledFromChild?:boolean): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space is needed after the colon in parameter to match the tslint rules

Suggested change
public requestLayout(calledFromChild?:boolean): void {
public requestLayout(calledFromChild?: boolean): void {


public requestLayout(): void {
super.requestLayout();
public requestLayout(calledFromChild?:boolean): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space is needed after the colon in parameter to match the tslint rules

Suggested change
public requestLayout(calledFromChild?:boolean): void {
public requestLayout(calledFromChild?: boolean): void {

if (this._isLayoutValid) {
return;
}
const width = this.getMeasuredWidth()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing semicolon

Suggested change
const width = this.getMeasuredWidth()
const width = this.getMeasuredWidth();

return;
}
const width = this.getMeasuredWidth()
const height = this.getMeasuredHeight()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing semicolon

Suggested change
const height = this.getMeasuredHeight()
const height = this.getMeasuredHeight()

Comment thread api-reports/NativeScript.api.md Outdated
public isPlaying: boolean;
// Warning: (ae-forgotten-export) The symbol "AnimationPromise" needs to be exported by the entry point index.d.ts
//
//
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you remove all these spaces?

* Invalidates the layout of the view and triggers a new layout pass.
*/
public requestLayout(): void;
public requestLayout(calledFromChild?:boolean): void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Space is needed after the colon in parameter to match the tslint rules

Suggested change
public requestLayout(calledFromChild?:boolean): void;
public requestLayout(calledFromChild?: boolean): void;

@farfromrefug
Copy link
Copy Markdown
Collaborator Author

@vtrifonov sorry about that :s All lint errors fixed

@vtrifonov
Copy link
Copy Markdown
Contributor

vtrifonov commented Jan 20, 2020

@farfromrefug, sorry, it should remain:

public requestLayout(calledFromChild?:boolean): void;

(without space after the parameter) in the api-reports/NativeScript.api.json file. You'd better run

npm run api-extractor

and then commit the api-reports/NativeScript.api.json file.

@farfromrefug
Copy link
Copy Markdown
Collaborator Author

@farfromrefug, sorry, it should remain:

public requestLayout(calledFromChild?:boolean): void;

(without space after the parameter) in the api-reports/NativeScript.api.json file. You'd better run

npm run api-extractor

and then commit the api-reports/NativeScript.api.json file.

My bad thought it was an error on my side :s

@farfromrefug
Copy link
Copy Markdown
Collaborator Author

I used those changes inside an app of mine.
We can easily the difference in the profiling

The first one is with {N} current behavior. The next one with those changes.
You can the deep calls to requestLayout on the first one. And they are not needed as the actual parent StackLayout(16) is not attached yet.
Screen Shot 2020-02-28 at 19 40 57
Screen Shot 2020-02-28 at 19 41 07

@NathanaelA

This comment was marked as abuse.

@farfromrefug
Copy link
Copy Markdown
Collaborator Author

@NathanaelA I honestly don't want to talk in time. More in unecessery deep calls..and in some cases those calls are long. But obviously there s time gain from this, not easy to compute though.

@NathanWalker
Copy link
Copy Markdown
Contributor

@farfromrefug flagging for 7.0 as we can test these changes with all other planned changes for 7.0 👍

@farfromrefug
Copy link
Copy Markdown
Collaborator Author

@NathanWalker this PR mostly exists to show the possible issues we have we layout

@NathanWalker
Copy link
Copy Markdown
Contributor

@farfromrefug we would like to get some of these improvements in for 8.0 and curious if you would want to collaborate on anything remaining here?

@NathanWalker NathanWalker added this to the 8.0 milestone Oct 27, 2020
@farfromrefug
Copy link
Copy Markdown
Collaborator Author

I am willing but it requires a lot of thinking. Upon deeper look at the iOS implementation it has a very deep flow. A view cannot request it s own relayout. It has to go all the way up to the view controller. We need to looknif this is fixable. Otherwise this PR should be discarded (hopefully not)

@NathanWalker NathanWalker changed the base branch from master to release/8.0.0 January 21, 2021 17:34
@NathanWalker NathanWalker changed the title testing improvements on layout perf: faster view layout handling Jan 21, 2021
@NathanWalker NathanWalker marked this pull request as ready for review January 29, 2021 19:45
@rigor789 rigor789 removed this from the 8.0 milestone Aug 4, 2021
@NathanWalker NathanWalker added this to the 8.4 milestone Aug 16, 2022
@NathanWalker NathanWalker removed this from the 8.4 milestone Nov 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants