Skip to content

UiKitView has buggy RenderObject #111788

@fzyzcjy

Description

@fzyzcjy

Copied from PR

How the bug is found

This bug is surely not found by human eyes reading each and every line of Flutter code :)

I proposed the idea that a linter can be created (dart-code-checker/dart-code-metrics#997) to validate whether RenderObject field setters have correct early-return code. @incendial implemented it and ran it (dart-code-checker/dart-code-metrics#1003).

Thus, thanks @incendial for implementing the linter and run it through flutter framework code!

Bug description

As we know, when implementing a setter in RenderObject, we usually early halt if the new value is equal to the old value (such as this one, indeed almost all fields in RenderObject child classes are examples). This is very necessary, because we are setting fields in updateRenderObject unconditionally. If we do not early return, we will execute the full logic like markNeedsPaint and so on unconditionally on every updateRenderObject. That will be performance penalty.

The current PR fixes one bug of such case. In more details, the viewController field setter lacks such early-return, and thus unconditionally calls markNeedsPaint. The setter is called from updateRenderObject as follows:

image

And _UiKitPlatformView is used here:

image

In other words, the controller is not changed in every frame. Instead, in common cases, it should be the same one for many frames. However, it triggers repaint for each and every rebuild.

Metadata

Metadata

Assignees

No one assigned

    Labels

    frameworkflutter/packages/flutter repository. See also f: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions