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

Conversation

@gaaclarke
Copy link
Member

I reviewed the code and I don't think this requirement is necessary. Offscreen MSAA is already guarded by a flag and looking at the opengles code it doesn't seem to be using multisample buffers.

When removing it the emulator no longer crashes and behaves identically to on device (which is rendering incorrect colors and crashing when pressing a the counter button).

fixes flutter/flutter#105323

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.

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

@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 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.

@gaaclarke gaaclarke changed the title Removed requirement for multisample buffers from egl setup. [Impeller] Removed requirement for multisample buffers from egl setup. Apr 5, 2023
@gaaclarke gaaclarke requested a review from chinmaygarde April 5, 2023 16:35
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

While the offscreen MSAA stuff is guarded behind a flag till we implement checks for GL_EXT_multisampled_render_to_texture, this one deals with onscreen rendering. That is the main FBO. I believe doing this will disable MSAA on the onscreen present on devices. We don't want that. We need to check for 4 first and then fall back to 1. Can you verify the MSAA behavior in render doc or perhaps eyeball it (it may be hard to tell though).

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 5, 2023
@chinmaygarde chinmaygarde removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 5, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 5, 2023

auto label is removed for flutter/engine, pr: 40944, due to This PR has not met approval requirements for merging. Changes were requested by {chinmaygarde}, please make the needed changes and resubmit this PR.
You have project association MEMBER and need 1 more review(s) in order to merge this PR.

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

@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 5, 2023

auto label is removed for flutter/engine, pr: 40944, due to - The status or check suite Windows windows_host_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

  • The status or check suite Linux linux_web_engine has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Linux Fuchsia FEMU has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 5, 2023

auto label is removed for flutter/engine, pr: 40944, due to - This pull request has changes requested by @chinmaygarde. Please resolve those before re-applying the label.

@chinmaygarde
Copy link
Member

Sorry about the autosub label. Added it by mistake.

@gaaclarke
Copy link
Member Author

That is the main FBO. I believe doing this will disable MSAA on the onscreen present on devices.

That sounds right. I didn't look closely since it is rendering kind of goofy. I'll tweak it this afternoon.

@gaaclarke gaaclarke requested a review from chinmaygarde April 5, 2023 20:25
attributes.push_back(static_cast<EGLint>(config.stencil_bits));
}

// On android emulators multisample buffer configs don't work, so we fallback
Copy link
Member

Choose a reason for hiding this comment

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

The stuff in //impeller/toolkit is meant to be platform agnostic. If a Samples::kFour config isn't found, this method will return nullptr to the caller. Can the caller can then try a different config? That way, this Android quirk doesn't affect other platforms.

I patched the Android stuff like so (don't know if it compiles but just a gist):

diff --git a/shell/platform/android/android_surface_gl_impeller.cc b/shell/platform/android/android_surface_gl_impeller.cc
index 3200822776..86437bb945 100644
--- a/shell/platform/android/android_surface_gl_impeller.cc
+++ b/shell/platform/android/android_surface_gl_impeller.cc
@@ -100,8 +100,17 @@ AndroidSurfaceGLImpeller::AndroidSurfaceGLImpeller(
   desc.surface_type = impeller::egl::SurfaceType::kWindow;
   auto onscreen_config = display->ChooseConfig(desc);
   if (!onscreen_config) {
-    FML_DLOG(ERROR) << "Could not choose onscreen config.";
-    return;
+    // This is probably an Android simulator. Fallback to a single sample so we
+    // get something up on the screen.
+    desc.samples = impeller::egl::Samples::kOne;
+    onscreen_config = display->ChooseConfig(desc);
+    if (onscreen_config) {
+      FML_LOG(INFO) << "Warning: This device doesn't support MSAA for onscreen "
+                       "framebuffers. Falling back to a single sample.";
+    } else {
+      FML_DLOG(ERROR) << "Could not choose onscreen config.";
+      return;
+    }
   }
 
   desc.surface_type = impeller::egl::SurfaceType::kPBuffer;

We actually don't want to use kOne because that would disable MSAA on the onscreen FBO. We are just doing it so something shows up on simulators. Let's do that only on Android and log a message when we do so we know something is expected to not work. Instead of silently breaking like here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, this does the retry but I can move it up to the android layer if we want. Third time is a charm.

@gaaclarke gaaclarke requested a review from chinmaygarde April 6, 2023 17:00
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

The stuff in android_surface_gl_impeller.cc lgtm. I don't think the update in display.cc is accurate though.

if (sample_count > 1) {
attributes.push_back(EGL_SAMPLE_BUFFERS);
attributes.push_back(1);
attributes.push_back(EGL_SAMPLES);
Copy link
Member

Choose a reason for hiding this comment

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

We want to specify sample count to 1 explicitly right? If the caller wants 1 and we specify no opinion, the implementation is allowed to select anything it wants (I think). We will not be respecting the caller opinion for 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't, egl fails on the emulator if you specify 1. You have to leave it undefined. I expect undefined would not give you MSAA. It isn't officially documented as such though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want me to add an undefined option in the ConfigDescriptor to be explicit?

Copy link
Member

Choose a reason for hiding this comment

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

egl fails on the emulator if you specify 1

Didn't know that.

Do you want me to add an undefined option in the ConfigDescriptor to be explicit?

No. This is fine.

LGTM still.

@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 6, 2023
@gaaclarke
Copy link
Member Author

blocked on flutter/flutter#124332

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 6, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Apr 6, 2023

auto label is removed for flutter/engine, pr: 40944, Failed to merge pr#: 40944 with Pull request could not be merged: Required status check "ci.yaml validation" is expected..

@gaaclarke
Copy link
Member Author

I'm following up in a different PR for unit tests since I had to refactor quite a bit to make it happen and this is already approved: #40979

zhongwuzw pushed a commit to zhongwuzw/engine that referenced this pull request Apr 14, 2023
flutter#40944)

I reviewed the code and I don't think this requirement is necessary.
Offscreen MSAA is already guarded by a flag and looking at the opengles
code it doesn't seem to be using multisample buffers.

When removing it the emulator no longer crashes and behaves identically
to on device (which is rendering incorrect colors and crashing when
pressing a the counter button).

fixes flutter/flutter#105323

## 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.
- [ ] 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].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[C++, Objective-C, Java style guides]:
https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
[testing the engine]:
https://github.com/flutter/flutter/wiki/Testing-the-engine
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
@RoliGautam21
Copy link

i am continously getting error of using impeller

flutter run --enable-impeller
Launching lib/main.dart on SM M127G in debug mode...
Running Gradle task 'assembleDebug'... 63.6s
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app-debug.apk... 17.3s
E/flutter (13092): [ERROR:flutter/shell/platform/android/android_surface_gl_impeller.cc(75)] Using the Impeller rendering backend.
W/FlutterActivityAndFragmentDelegate(13092): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.

Additional info:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on Ubuntu 20.04.6 LTS 5.15.0-71-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.3)
[✓] VS Code
[✓] Connected device (3 available)
[✓] HTTP Host Availability

@gaaclarke
Copy link
Member Author

i am continously getting error of using impeller

@RoliGautam21 you should file an issue with reproduction steps. There's nothing in that log that suggests it's related to this PR.

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.

[Impeller] Crash on Android Emulator

3 participants