engine icon indicating copy to clipboard operation
engine copied to clipboard

Avoid object creation during each frame

Open simonla opened this issue 2 years ago • 2 comments

Choreographer.FrameCallback will be called each frame

We should avoid create new object here

There is no need to consider thread safety here, because it is guaranteed here and here

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I signed the CLA.
  • [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

simonla avatar Aug 11 '22 16:08 simonla

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

flutter-dashboard[bot] avatar Aug 11 '22 16:08 flutter-dashboard[bot]

It looks like we will only have one request at same time

So we can hold one FrameCallback instance safely

animator.cc:

  if (!pending_frame_semaphore_.TryWait()) {
    // Multiple calls to Animator::RequestFrame will still result in a
    // single request to the VsyncWaiter.
    return;
  }

simonla avatar Aug 11 '22 17:08 simonla

  • Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

auto-submit[bot] avatar Aug 17 '22 17:08 auto-submit[bot]

Validations Fail.

auto-submit[bot] avatar Aug 17 '22 17:08 auto-submit[bot]

Validations Fail.

@jason-simmons help~ 👀

simonla avatar Aug 18 '22 12:08 simonla

@simonla this needed a second reviewer, I've approved. Asking for a NTE from @Hixie

dnfield avatar Aug 18 '22 16:08 dnfield

test-exempt: code refactor with no semantic change

Hixie avatar Aug 18 '22 17:08 Hixie

@jason-simmons Got test-exempt and two approver. Would you mind helping me add the autosubmit tag again?

simonla avatar Aug 18 '22 18:08 simonla