[Android][Impeller][OpenGLES] EGL_BAD_ACCESS after recreating an Activity with a retained engine and hybrid-composed WebView

Ouverte
#197,541 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
12/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
android, cpp, dart
Domaine
mobile-dev

Piste de recherche

The suspected path is Rasterizer::Teardown() in engine/src/flutter/shell/common/rasterizer.cc, where the render context is made current and surface_ is reset before the raster and platform threads are unmerged. Read the merge/unmerge callback that calls ClearRenderContext(), then try to reproduce with a retained FlutterEngine and hybrid-composed WebView on an Android device. Done would be a fix validated across repeated activity recreations, with a regression test.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

What happens

With Impeller/OpenGLES, reopening an Android activity on the same FlutterEngine can leave the Flutter part of the screen black while an embedded WebView remains visible and scrollable. Dart still handles the back action, but the Flutter confirmation dialog never appears. I would expect the new FlutterView to render the existing route and respond visibly to input.

Steps that reproduce this in our app
  1. Use a process-owned FlutterEngine. The activity returns it from provideFlutterEngine and returns false from shouldDestroyEngineWithHost. An Android foreground service keeps the process alive.
  2. Open a route containing a WebView using hybrid composition, with a Flutter toolbar above it.
  3. Swipe the app away from Recents while that route is visible. Relaunch it from the launcher. The PID stays the same and a new activity attaches to the retained engine.

This was reported on a Pixel 10 Pro XL running Android 16 (2/2 from the WebView route, 0/3 from the home route). I also reproduced it on a Samsung SM-S936U running Android 17 with Flutter 3.41.9 (revision 00b0c91f062, arm64 debug build, Impeller/OpenGLES explicitly selected). Skia recovered on the same Samsung device. Reproduction so far is in the app; I have not yet tested current Flutter stable or main.

What the EGL trace shows

An Android GLES debug layer recorded these calls in one failing run. C identifies the same EGL context throughout; S1 and S2 are different draw surfaces.

11:53:52.887  old activity starts destruction
11:53:52.898  platform thread 17600  eglMakeCurrent(C, old draw surface) -> success
11:53:53.920  new activity created in the same process
11:53:53.976  raster thread 17672    eglMakeCurrent(C, S1) -> EGL_BAD_ACCESS
11:53:53.977  raster thread 17672    eglMakeCurrent(C, S2) -> EGL_BAD_ACCESS

The engine repeatedly logs Could not make the context current to acquire the frame. The new Android surface reports valid. In a control run, releasing the identified context once on its owning platform thread during teardown allowed the raster thread to bind it successfully after relaunch. With an app-side workaround that releases the matching context after native surface teardown, three consecutive activity recreations succeeded in the same process, including navigating back from the WebView.

Suspected engine path and follow-up

In 3.41.9, Rasterizer::Teardown() makes the render context current and resets surface_ before unmerging the raster and platform threads. The merge/unmerge callback checks surface_ before calling ClearRenderContext(). This ordering appears consistent with the binding left on the platform thread. Rasterizer source at the tested revision.

I plan to reduce this to a standalone reproduction, check current stable and main, and work on an engine fix if it still reproduces. I’ll validate the fix on physical Android devices with a retained engine and hybrid composition, add regression coverage, and follow up here with the results and a PR.

Langage dominant
Dart
Étoiles
182k
Forks
32k
Merge moyen
1 j 23 h
PR mergées (30 j)
352

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de flutter/flutter

Toutes les issues de flutter/flutter

Issues similaires

Plus d'issues Dart

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.