Commit Graph

19 Commits

Author SHA1 Message Date
Andrew Kolos
d88e692895
fix test chrome.close can recover if getTab throws a StateError (#154889)
Fixes https://github.com/flutter/flutter/issues/154857.

Does so by:
* adding `await chromiumLauncher.connect(chrome, false);` before the `close` call to make sure we enter[ the block ](9cd2fc90af/packages/flutter_tools/lib/src/web/chrome.dart (L521-L535))that actually tries to close chromium
* adding an `onGetTab` callback to `FakeChromeConnectionWithTab`, which the test now uses to throw a StateError upon `getTab` getting called.

## How I verified this change

1. Change `Chromium.close` from using the safer `getChromeTabGuarded` function to using the previous method of calling `ChromeConnection.getTab` directly. Do so by applying this diff:

```diff
diff --git a/packages/flutter_tools/lib/src/web/chrome.dart b/packages/flutter_tools/lib/src/web/chrome.dart
index c9a5fdab81..81bc246ff9 100644
--- a/packages/flutter_tools/lib/src/web/chrome.dart
+++ b/packages/flutter_tools/lib/src/web/chrome.dart
@@ -520,7 +520,7 @@ class Chromium {
     Duration sigtermDelay = Duration.zero;
     if (_hasValidChromeConnection) {
       try {
-        final ChromeTab? tab = await getChromeTabGuarded(chromeConnection,
+        final ChromeTab? tab = await chromeConnection.getTab(
             (_) => true, retryFor: const Duration(seconds: 1));
         if (tab != null) {
           final WipConnection wipConnection = await tab.connect();
```

2. Then, run the test, which should correctly fail:
```
dart test test/web.shard/chrome_test.dart --name="chrome.close can recover if getTab throws a StateError"`
```
3. Revert the change from step 1 and run again. The test should now pass.
2024-09-10 17:23:56 +00:00
Andrew Kolos
a8528c70b6
catch StateError thrown from Chromium.close (#154366)
Fixes crasher https://github.com/flutter/flutter/issues/154203.

Also does a little refactoring to move exception handling into the `getChromeTabGuarded` utility function.

I plan on cherry-picking a subset of this change. This would be included in the custom CP patch for https://github.com/flutter/flutter/issues/153064.
2024-08-30 00:01:12 +00:00
Yegor
93dc40916c
[web:tools] disable search engine choice screen in flutter run (#154059)
The choice screen is irrelevant when debugging apps locally. `flutter run` creates a separate user profile for testing only. It doesn't touch users' browser settings.

Fixes https://github.com/flutter/flutter/issues/153928
2024-08-27 17:00:13 +00:00
Andrew Kolos
9ec2588fd0
handle IOExceptions coming from ChromeTab.connect (#153978)
Fixes https://github.com/flutter/flutter/issues/153972  (unless the cause of https://github.com/flutter/flutter/issues/153064#issuecomment-2305662791 happens to also prevent this fix from working).

In this PR, I've looked for all non-test call sites of `ChromeConnection.getTabs` and made sure are all wrapped in `try` blocks that handle `IOException` (`HttpException` is what we see in crash reporting, but I figure any `IOException` might as well be the same for all intents and purposes).

I plan on cherry-picking this the stable branch.
2024-08-27 16:19:28 +00:00
Jason Simmons
49a315284d
Handle a WebSocketException that may be thrown when closing the WebKit inspection protocol connection to Chrome (#151997)
Noticed this happening on macOS when the tool tries to shut down Chrome after all tabs have already been closed.
2024-07-19 17:58:26 +00:00
Jason Simmons
b373fa2c6e
Handle a SocketException thrown when sending the browser close command to Chrome (#151197)
https://github.com/flutter/flutter/pull/150645 tries to shut down Chrome by sending a browser close command through a debug protocol.  The webkit_inspection_protocol library used to send the command may throw a SocketException if Chrome has already been shut down.
2024-07-03 13:23:20 +00:00
Jason Simmons
9afd397cd4
[flutter_tools] Shut down Chromium cleanly using a command sent through the debug protocol (#150645)
The previous approach of killing the Chromium parent process sometimes caused leaks of child processes on Windows.  The Browser.close command in the debug protocol will tell Chromium to shut down all of its processes.
2024-06-25 21:43:02 +00:00
Yegor
371aadd822
[tool] fallback to sigkill when closing Chromium (#135521)
This implements https://github.com/flutter/flutter/issues/132654#issuecomment-1738221257, namely:

Make `Chromium.close` more robust:

* Send `SIGTERM` and wait up to 5 seconds, if the process exited, great! Return from the function.
* If the process has not exited, then send a `SIGKILL`, which is a much firmer way to exit a process. Same as before, wait up to 5 seconds, if the process exited, great! Return from the function.
* If it still hasn't exited then give up trying to exit Chromium, just print a warning to the console and return from the function.

Bonus: a few nullability fixes and extra `-v` logging.

Fixes https://github.com/flutter/flutter/issues/132654
2023-09-28 22:28:31 +00:00
Yegor
d6d2e89fc8
finer grained logging of Chromium launch sequence (#135078)
Log the details of how Chromium is about to be launched prior to running
the Chromium command, as well as the path to the Chromium executable.

This should improve our understanding of what's happening here:
https://github.com/flutter/flutter/issues/132654#issuecomment-1726630123
2023-09-20 15:20:16 -07:00
Pascal Welsch
25c2c22d29
Delete Chrome temp cache after closing (#119062)
* Delete Chrome temp cache after closeing

* Update packages/flutter_tools/lib/src/web/chrome.dart

Co-authored-by: Christopher Fujino <fujino@google.com>

---------

Co-authored-by: Christopher Fujino <fujino@google.com>
2023-02-10 17:39:58 +00:00
Zachary Anderson
c6ec84e978
[flutter_tools] Pull more arm64 artifacts on Apple Silicon (#110291) 2022-08-29 10:33:24 -07:00
Gustl22
47f54ace45
feat(tools): Arbitrary browser flags (closes #65575) (#104935) 2022-06-24 10:14:08 -07:00
Anna Gringauze
5cd979e441
Retry getting tabs in chrome launcher on ConnectionException (#104218) 2022-05-26 15:20:11 -07:00
Alexandre Ardhuin
07f1c20474
add missing trailing commas in list/set/map literals (#102585) 2022-04-27 09:15:35 +02:00
Anna Gringauze
ca62470796
De-flake web tool tests (#93948) 2021-11-30 17:39:05 -08:00
Ian Hickson
61a0add286
Enable avoid_redundant_argument_values lint (#91409) (#91462) 2021-10-08 09:25:14 -07:00
Zachary Anderson
b9d2177da0
Revert "Enable avoid_redundant_argument_values lint (#91409)" (#91461)
This reverts commit 5fd259be24.
2021-10-07 21:11:07 -07:00
Ian Hickson
5fd259be24
Enable avoid_redundant_argument_values lint (#91409) 2021-10-07 20:13:02 -07:00
Ian Hickson
4315cdcf76
Some test cleanup for flutter_tools. (#90227) 2021-10-01 10:38:02 -07:00