Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Nov 18, 2020

Description

We used to clear composition_order_ in the end of the frame. This caused an issue with a frame drawn by drawLastlayerTree, because the endFrame is not called in such a frame. This causes a crash where a texture layer is constantly updating on top of a platform view, due to the same view_id is pushed to composition_order_ multiple times. (Again, because composition_order_ is not cleared)

This PR moves the composition_order_.clear() to the beginning of each frame.

This PR also removed FlutterViewController::EndFrame as it is not used anymore.

Related Issues

Fixes flutter/flutter#70577

Tests

I added the following tests:

testPlatformViewWithContinuousTexture

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the contributor guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the C++, Objective-C, Java style guides for the engine.
  • I read the tree hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.
  • I am willing to follow-up on review comments in a timely manner.

Reviewer Checklist

Breaking Change

Did any tests fail when you ran them? Please read handling breaking changes.


void FlutterPlatformViewsController::SetFrameSize(SkISize frame_size) {
void FlutterPlatformViewsController::BeginFrame(SkISize frame_size) {
composition_order_.clear();
Copy link

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

could we also have a unit test for this?

Copy link

Choose a reason for hiding this comment

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

could we make aReset() method, similar to Android? Why not also clearing picture_recorders_?

- (CVPixelBufferRef)pixelBuffer
{
NSDictionary *options = @{
(NSString*)kCVPixelBufferCGImageCompatibilityKey : @YES,
Copy link

Choose a reason for hiding this comment

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

do you mind adding some comments explaining why this is all needed?


@override
void onBeginFrame(Duration duration) {
print('begin frame');
Copy link

Choose a reason for hiding this comment

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

is this intentional?

print('begin frame');
final SceneBuilder builder = SceneBuilder();

builder.pushOffset(0, 0);
Copy link

Choose a reason for hiding this comment

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

nit: this is a noop

}
}

/// A simple platform view for testing platform view with a continuous texture layer.
Copy link

Choose a reason for hiding this comment

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

what does continuous texture mean? Does it mean a texture that simulates a video being played?

@cyanglaz
Copy link
Contributor Author

@blasten updated per comments. PTAL

@mehmetf
Copy link
Contributor

mehmetf commented Nov 18, 2020

Folks, since this is a regression, let's try to get it in today to see whether we can land it internally by end of the week. It will be tight if at all possible.

std::make_unique<flutter::EmbeddedViewParams>(finalMatrix, SkSize::Make(300, 300), stack);
flutterPlatformViewsController->PrerollCompositeEmbeddedView(0, std::move(embeddedViewParams1));
flutterPlatformViewsController->CompositeEmbeddedView(0);
XCTAssertEqual(flutterPlatformViewsController->GetCurrentCanvases().size(), (unsigned long)1);
Copy link

Choose a reason for hiding this comment

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

does 1UL work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, updated

flutterPlatformViewsController->CompositeEmbeddedView(0);
XCTAssertEqual(flutterPlatformViewsController->GetCurrentCanvases().size(), (unsigned long)1);

flutterPlatformViewsController->Reset();
Copy link

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, removed


// Second frame, |GetCurrentCanvases| should be empty at the start
flutterPlatformViewsController->BeginFrame(SkISize::Make(300, 300));
XCTAssertEqual(flutterPlatformViewsController->GetCurrentCanvases().size(), (unsigned long)0);
Copy link

Choose a reason for hiding this comment

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

nit: XCTAssertTrue(flutterPlatformViewsController->GetCurrentCanvases().empty())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!


CGContextDrawImage(context, CGRectMake(0, 0, width, height), self.image.CGImage);
CGColorSpaceRelease(rgbColorSpace);
CGContextRelease(context);
Copy link

Choose a reason for hiding this comment

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

What parts of this method are essential to test and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not required. removed.

Copy link

@blasten blasten left a comment

Choose a reason for hiding this comment

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

LGTM

@cyanglaz cyanglaz added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Nov 18, 2020
Copy link
Contributor

@iskakaushik iskakaushik left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 19, 2020
mehmetf added a commit that referenced this pull request Nov 26, 2020
chaselatta pushed a commit to chaselatta/engine that referenced this pull request Nov 30, 2020
cyanglaz pushed a commit to cyanglaz/engine that referenced this pull request Dec 8, 2020
christopherfujino pushed a commit that referenced this pull request Dec 9, 2020
* PlatformViewsController: clear composition_order_ in the beginning of each frame. (#22574)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-ios waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flutter crash while using Camera plugin on iOS

5 participants