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

Add test for external textures on Android #26109

Closed
wants to merge 4 commits into from

Conversation

ds84182
Copy link
Contributor

@ds84182 ds84182 commented May 12, 2021

This PR adds three tiers of tests for external texture rendering, along with comparisons for Android's SurfaceView.

  • Identity transforms
  • Surface rotations. This requires decoding a video through MediaCodec with the rotation parameter set. Android framework source basically passes through the rotation parameter to the underlying Surface.
  • Surface crops, and surface rotations + crops. This requires the use of ImageReader (21+) and ImageWriter (23+). MediaCodec presents directly into the ImageReader, the crop rect is set on the acquired Images, and then the images are sent to ImageWriter which presents to the screen. The crop rect (which we now control) and rotation (passed from MediaCodec) are applied directly to the underlying Surface. Note that "Image" is a bit of a misnomer, they're actually just presentable hardware buffers.

Part of #24888

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • 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.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.
  • The reviewer has submitted any presubmit flakes in this PR using the engine presubmit flakes form before re-triggering the failure.

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

@google-cla google-cla bot added the cla: yes label May 12, 2021
@ds84182 ds84182 marked this pull request as ready for review May 12, 2021 22:22
@ds84182 ds84182 requested a review from gaaclarke May 12, 2021 22:22
@chinmaygarde
Copy link
Member

Ping @gaaclarke and @blasten for routing.

@gaaclarke
Copy link
Member

gaaclarke commented May 22, 2021

I'm sorry, I skipped over this because rarely does anything Android have to do with me. The code LGTM and tests seem representative. I honestly don't know the Android integration tests system. It would be worth checking with @blasten there, @blasten ping me Monday if you want me to talk you through the context of the test.

Let's get this guy merged asap, if it gets stuck somehow message me on chat.

@ds84182 ds84182 requested a review from blasten May 26, 2021 01:01
@gaaclarke
Copy link
Member

friendly ping @blasten

@blasten
Copy link

blasten commented Jun 3, 2021

The current process for checking in the golden files isn't accurately documented. I need to fix this issue.

For the time being, you could go to the "Linux Android Scenarios" check page. Check the output of Scenario App Integration Tests to see which tests have failed. The latest ones are these.

Find the "gsutil upload "flutter/{something}/diff_failures.zip". The latest one is this zip.

Replace the .png files in the engine repo that are different from the ones that end with *_actual.png within the zip file. This means removing the *_actual.png prefix and then copying the files over.

return atomicCanProduceFrames.get();
}

private void decodeThreadMain() {
Copy link

Choose a reason for hiding this comment

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

Is the logic below strictly necessary? Ideally, the test would be as simple as possible if it can capture the behavior you want to make sure doesn't break.

class DisplayTexture extends Scenario {
/// Creates the DisplayTexture scenario.
///
/// The [dispatcher] parameter must not be null.
Copy link

Choose a reason for hiding this comment

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

our style docs mentions that it's preferred to avoid comments that can otherwise be communicated through the type system or the method signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Omitting the comment fails a lint check, so I don't think this can be removed. This matches whats done in other test scenarios.

@blasten
Copy link

blasten commented Jun 3, 2021

@ds84182 It doesn't appear that #24888 deals with video although plugins use textures to display video. What do you think about faking a frame? Maybe using android.graphics.Canvas so we don't need the video.

@ds84182
Copy link
Contributor Author

ds84182 commented Jun 3, 2021

The problem with using andorid.graphics.Canvas is that you can't specify surface rotations with it. Video decoding allows you to specify arbitrary rotations, and surface crops didn't seem to work correctly when sourced from a Canvas.

Most of the issues with external textures are from Flutter not supporting rotations and crops correctly, which is what #24888 fixes. If Android made it easy to specify rotations and crops, this PR would be simple.

@blasten
Copy link

blasten commented Jun 3, 2021

I see. Thanks for the explanation @ds84182.

My only last comment would be to add more comments to test code.

@ds84182
Copy link
Contributor Author

ds84182 commented Jun 4, 2021

@blasten Looks like the diff failures are for other scenario tests. Should I still add them to the PR?

@blasten
Copy link

blasten commented Jun 4, 2021

I saw that. Yes. That sounds good

@chinmaygarde
Copy link
Member

@blasten Another review after the latest updates?

@blasten
Copy link

blasten commented Jun 10, 2021

This is waiting on #24888. Other than that LGTM

@ds84182
Copy link
Contributor Author

ds84182 commented Jun 11, 2021

Actually the opposite, #24888 is waiting on this CL since it's the only way to verify the changes are correct.

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

@chinmaygarde
Copy link
Member

The Firebase Test Lab failures look related to this patch. Can we ensure presubmits pass please?

@chinmaygarde
Copy link
Member

The linux presubmit failure is just a minor formatting fix. I am not sure how to troubleshoot the Firebase Test Lab failure. Perhaps @blasten can help?

android:windowSoftInputMode="adjustResize"
android:theme="@style/FullScreenScreenshot">
<intent-filter>
<action android:name="com.google.intent.action.TEST_LOOP" />
Copy link

Choose a reason for hiding this comment

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

this seems correct. I wonder if the issue is that only one activity can have this action. What happens if you remove the content of the outer <intent-filter>?

@chinmaygarde
Copy link
Member

Any updates here?

@chinmaygarde
Copy link
Member

Closing this as stale. Please reopen if progress is possible and once the conflicts are solved.

@blasten
Copy link

blasten commented Jul 15, 2021

@ds84182 feel free to reach out to me if you'd like to try to land your change. I know it's very painful to contribute to some of our repos, but we are trying to improve that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants