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

Conversation

@designDo
Copy link
Contributor

@flutter-dashboard
Copy link

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 or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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.

@designDo designDo reopened this Nov 11, 2023
@designDo designDo closed this Nov 13, 2023
@designDo designDo reopened this Nov 13, 2023
@johnmccutchan
Copy link
Contributor

Hi,

Can you please update your branch so it can be merged?

Also, how can write a test for this scenario?

@johnmccutchan johnmccutchan self-requested a review November 14, 2023 15:27
// When 'hot reload', although the resize method is triggered, the size of the native View has
// not changed.
if (width == getRenderTargetWidth() && height == getRenderTargetHeight()) {
getView().postDelayed(onNewSizeFrameAvailable, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the contract around onNewSizeFrameAvailable? In the case that the size doesn't change do we need to run it?

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, postDelayed can be removed

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this is true, it must be called.

return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
resizeAboveAndroidS(getView(), width, height, onNewSizeFrameAvailable);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use the numeric version instead of S:

resize31(...);

renderTarget.release();
}

@TargetApi(21)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be 31

private void resizeAboveAndroidS(
View embeddedView, int width, int height, final Runnable onNewSizeFrameAvailable) {
renderTarget.resize(width, height);
// https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-30/+/refs/heads/master/android/app/Presentation.java#293
Copy link
Contributor

Choose a reason for hiding this comment

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

Rewrite this comment block as:

// On Android versions 31+ resizing of a Virtual Display's Presentation is natively supported.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please address this comment.

@designDo designDo closed this Nov 15, 2023
@designDo designDo reopened this Nov 15, 2023
@designDo
Copy link
Contributor Author

@johnmccutchan hi, thanks for code review. I have merge main branch to pre/128920.
https://github.com/designDo/video_player_surface , this repo can be used to test SurfaceView play on Android 31+.

@designDo
Copy link
Contributor Author

something wrong with build windows, https://github.com/flutter/engine/pull/47946/checks?check_run_id=18690556117
I see the build log, It doesn’t seem to be a code problem.

@johnmccutchan
Copy link
Contributor

@johnmccutchan hi, thanks for code review. I have merge main branch to pre/128920. https://github.com/designDo/video_player_surface , this repo can be used to test SurfaceView play on Android 31+.

By a test I mean an automated test that is part of this PR.

@johnmccutchan
Copy link
Contributor

@designDo Are you going to address my other comments?

@designDo
Copy link
Contributor Author

@designDo Are you going to address my other comments?

I modified everything mentioned in the code review

@designDo
Copy link
Contributor Author

@johnmccutchan hi, thanks for code review. I have merge main branch to pre/128920. https://github.com/designDo/video_player_surface , this repo can be used to test SurfaceView play on Android 31+.

By a test I mean an automated test that is part of this PR.

@johnmccutchan hi, thanks for code review. I have merge main branch to pre/128920. https://github.com/designDo/video_player_surface , this repo can be used to test SurfaceView play on Android 31+.

By a test I mean an automated test that is part of this PR.
how to do this

Copy link
Contributor

@johnmccutchan johnmccutchan left a comment

Choose a reason for hiding this comment

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

Just a couple nits left and then I will approve. Thanks for the contribution!

private void resizeAboveAndroidS(
View embeddedView, int width, int height, final Runnable onNewSizeFrameAvailable) {
renderTarget.resize(width, height);
// https://android.googlesource.com/platform/prebuilts/fullsdk/sources/android-30/+/refs/heads/master/android/app/Presentation.java#293
Copy link
Contributor

Choose a reason for hiding this comment

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

Please address this comment.

// When 'hot reload', although the resize method is triggered, the size of the native View has
// not changed.
if (width == getRenderTargetWidth() && height == getRenderTargetHeight()) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

After reading the calling code, we do need to run the onNewSizeFrameAvailable in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Meaningless comments have been removed.
In this case, added onNewSizeFrameAvailable callback.
Thank you for your guidance and help!

View embeddedView, int width, int height, final Runnable onNewSizeFrameAvailable) {
renderTarget.resize(width, height);
// On Android versions 31+ resizing of a Virtual Display's Presentation is natively supported.
// Fix in: https://github.com/flutter/flutter/issues/128920
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the comment "// Fix in: ..." as it isn't needed in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, this line has removed. I have merged main into pre/128920.

@johnmccutchan johnmccutchan merged commit 70b1c73 into flutter:main Nov 21, 2023
@johnmccutchan
Copy link
Contributor

Thanks for your contribution!

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 21, 2023
@designDo designDo deleted the pre/128920 branch November 23, 2023 12:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PlatformView][Android] Unexpected behavior when embedding an Android SurfaceView

2 participants