flutter / flutter/devtools

DevTools set `debugDefaultTargetPlatformOverride` but don't reset it, causing assertions to be broken

Abierto
#6,719 5 comentarios 0 reacciones 0 asignados Ver en GitHub
bug devtools extensions P2
Lenguaje dominante
Dart
Estrellas
1.7k
Forks
404
Merge medio
6 d 17 h
PR fusionados (30 d)
18

Descripción

### Problem

The DevTools call `FoundationServiceExtensions.platformOverride`, which [modifies](https://github.com/flutter/flutter/blob/f70a01c69165561d7754a6882a124d11fe6da4e6/packages/flutter/lib/src/foundation/binding.dart#L568) the value of [`debugDefaultTargetPlatformOverride`](https://github.com/flutter/flutter/blob/f70a01c69165561d7754a6882a124d11fe6da4e6/packages/flutter/lib/src/foundation/platform.dart#L98).

This causes tests (that are being run when the DevTools are enable) to fail because the assertion in [`TestWidgetsFlutterBinding._runTestBody()`](https://github.com/flutter/flutter/blob/3.16.0/packages/flutter_test/lib/src/binding.dart#L996) is violated:

https://github.com/flutter/flutter/blob/0cdb3bf582f00cbb9bc4a3701263ab655b09db69/packages/flutter/lib/src/foundation/debug.dart#L28-L39

### Proposed solution

- DevTools should take care of resettnig `debugDefaultTargetPlatformOverride` (and possibly other values it might set) during the tests.

- DevTools (and its extension ecosystem) should probably be tested on more test-like scenarious – when the app's entrypoint is a widget/integration tests. This would prevent issues like this in the future.

### Workaround

We have adopted [a temporary workaround](https://github.com/leancodepl/patrol/pull/1829/commits/778b4ede1e153c4505489d59a71e1c8c0fa46575) - save the value of `debugDefaultTargetPlatformOverride` sometime at the beginning of the test, and restore it near the end.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.