flutter / flutter/devtools

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

オープン
#6,719 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug devtools extensions P2
主要言語
Dart
スター
1.7k
フォーク
404
平均マージ
6日 17時間
マージ済み PR(30日)
18

説明

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

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。