RenderListWheelViewport creates a new OpacityLayer on every paint and keeps it after it stops using it
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- dart
- Área
- mobile-dev
Línea de trabajo
La corrección está en packages/flutter/lib/src/rendering/list_wheel_viewport.dart: la llamada a pushOpacity cerca de la línea 832 no pasa oldLayer, y el handle de la capa no se limpia en la rama de opacidad 1 (alrededor de la línea 825) ni en la rama sin hijos (alrededor de la línea 794). Empieza ejecutando los dos testWidgets del issue con flutter test para ver los fallos. Está terminado cuando la capa se reutiliza entre repintados y se libera (dispose) cuando la opacidad es 1 o no hay hijos, y ambos tests pasan.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Steps to reproduce
- Show a
ListWheelScrollViewwithoverAndUnderCenterOpacitybelow 1. EveryCupertinoPickerdoes this (it uses 0.447). - Scroll it.
- Set
overAndUnderCenterOpacityto 1, or remove all children.
The code sample below shows this with flutter test.
Expected results
The viewport reuses its OpacityLayer across repaints, like it already does for its clip layer, and releases it once it no longer needs it.
Actual results
pushOpacity is called without oldLayer (L832), so every paint creates a new OpacityLayer. The handle added in #136576 is also not cleared when the opacity becomes 1 (L825) or when there are no children (L794). The detached layer and its children stay alive until the opacity drops below 1 again, or until the render object is disposed.
In a profile build with four CupertinoPickers scrolling, that's 240 new OpacityLayers every 60 frames instead of 4. I didn't see a frame-time difference on Linux desktop with software rendering, so this is about layer reuse and memory, not speed.
Code sample
Code sample
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
Widget wheel({FixedExtentScrollController? controller, double opacity = 0.5}) {
return Directionality(
textDirection: TextDirection.ltr,
child: ListWheelScrollView(
controller: controller,
overAndUnderCenterOpacity: opacity,
itemExtent: 20,
children: <Widget>[for (int i = 0; i < 20; i++) Container()],
),
);
}
void main() {
testWidgets('reuses the OpacityLayer when it repaints', (WidgetTester tester) async {
final controller = FixedExtentScrollController();
addTearDown(controller.dispose);
await tester.pumpWidget(wheel(controller: controller));
final OpacityLayer layer = tester.layers.whereType<OpacityLayer>().single;
controller.jumpTo(50);
await tester.pump();
expect(tester.layers.whereType<OpacityLayer>().single, same(layer)); // Fails.
});
testWidgets('releases the OpacityLayer at opacity 1', (WidgetTester tester) async {
await tester.pumpWidget(wheel());
final OpacityLayer layer = tester.layers.whereType<OpacityLayer>().single;
await tester.pumpWidget(wheel(opacity: 1));
expect(tester.layers.whereType<OpacityLayer>(), isEmpty); // Passes.
expect(layer.debugDisposed, isTrue); // Fails.
});
}
Screenshots or Video
N/A
Logs
Logs
Expected: same instance as OpacityLayer:<OpacityLayer#3fef1 DETACHED(handles: 0, offset: Offset(0.0, 0.0), alpha: 128)>
Actual: OpacityLayer:<OpacityLayer#eb26c(engine layer: OpacityEngineLayer#96f04, handles: 2, offset: Offset(0.0, 0.0), alpha: 128)>
Expected: true
Actual: <false>
Flutter Doctor output
Doctor output
Run with `flutter test` on master 6e582bb058d6 (3.51.0-1.0.pre-406), engine 0fb0ab6f8809, Dart 3.15.0-186.0.dev, Linux x64.
I have a fix with regression tests and will open a PR for it. It's 5 lines: pass the old layer back, and clear the handles in the two cases above.
- Lenguaje dominante
- Dart
- Estrellas
- 182k
- Forks
- 32k
- Merge medio
- 1 d 23 h
- PR fusionados (30 d)
- 359
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de flutter/flutter
-
a: text input engine found in release: 3.50 fyi-text-input platform-ios team-ios workaround available
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
flutter/flutter#197531 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
flutter/flutter#197514 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
[video_player] _updatePosition sets isCompleted=true after 500ms when duration is Duration.zeroAbiertop: video_player package team-ecosystem
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
flutter/flutter#197494 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
a: typography dependency: skia engine found in release: 3.50 has reproducible steps team-engine
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
flutter/flutter#197467 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
[video_player] dispose() never completes if initialize() fails to create the playerPosiblemente ocupada @a1rwulf la tomó hace 5 días. Abiertoa: plugins fyi-ecosystem has reproducible steps p: video_player package platform-ios team-ios
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
flutter/flutter#197204 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de flutter/flutter
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
commetchat/commet#1123 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lichess-org/mobile#4099 ·
Los mantenedores suelen responder en 1 día
-
BUG: App crashes on iOS when initializing speech-to-text due to missing microphone and speech recognition keys in Info.plistPosiblemente ocupada @AyushSrivastava1818 la tomó hoy. Abiertobug enhancement
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
AOSSIE-Org/Ell-ena#365 · 2 comentarios ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
spotiflacapp/SpotiFLAC-Mobile#995 ·
-
feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
VeryGoodOpenSource/vgv-ai-flutter-plugin#219 · 1 comentario ·
Los mantenedores suelen responder en 1 día