Skip to content

[webview_flutter_android] Garbage collection tests are failing  #159500

@bparrishMines

Description

@bparrishMines

To test that objects are collected for webview_flutter_android, the tests use IntegrationTestWidgetsFlutterBinding.watchPerformance to force the garbage collector to run in Dart. However, calling this during integration tests causes this error:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following StateError was thrown running a test:
Bad state: Failed to connect to VM Service at ws://localhost:56445/Jw3X0DnPT7Y=/ws.
This may happen if DDS is enabled. If this test was launched via `flutter drive`, try adding
`--no-dds`.
The original exception was:
SocketException: Connection refused (OS Error: Connection refused, errno = 111), address =
localhost, port = 46384
#0      _NativeSocket.startConnect (dart:io-patch/socket_patch.dart:824:35)
#1      _RawSocket.startConnect (dart:io-patch/socket_patch.dart:2281:26)
#2      RawSocket.startConnect (dart:io-patch/socket_patch.dart:41:23)
#3      Socket._startConnect (dart:io-patch/socket_patch.dart:2561:22)
#4      Socket.startConnect (dart:io/socket.dart:890:21)
#5      _ConnectionTarget.connect (dart:_http/http_impl.dart:2686:24)
#6      _HttpClient._getConnection.connect (dart:_http/http_impl.dart:3200:12)
#7      _HttpClient._getConnection (dart:_http/http_impl.dart:3205:12)
#8      _HttpClient._openUrl (dart:_http/http_impl.dart:3028:12)
#9      _HttpClient.openUrl (dart:_http/http_impl.dart:2850:7)
#10     _WebSocketImpl.connect (dart:_http/websocket_impl.dart:1096:10)
#11     WebSocket.connect (dart:_http/websocket.dart:332:24)
#12     _vmServiceConnectUri (package:integration_test/integration_test.dart:482:44)
#13     IntegrationTestWidgetsFlutterBinding.enableTimeline
(package:integration_test/integration_test.dart:270:28)
<asynchronous suspension>
#14     IntegrationTestWidgetsFlutterBinding.traceTimeline
(package:integration_test/integration_test.dart:302:5)
<asynchronous suspension>
#15     IntegrationTestWidgetsFlutterBinding._runAndGetGCInfo
(package:integration_test/integration_test.dart:377:34)
<asynchronous suspension>
#16     IntegrationTestWidgetsFlutterBinding.watchPerformance
(package:integration_test/integration_test.dart:432:43)
<asynchronous suspension>
#17     main.<anonymous closure>
(file:///Users/bmparr/Development/packages/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart:100:5)
<asynchronous suspension>
#18     testWidgets.<anonymous closure>.<anonymous closure>
(package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#19     TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1027:5)
<asynchronous suspension>
#20     StackZoneSpecification._registerCallback.<anonymous closure>
(package:stack_trace/src/stack_zone_specification.dart:114:42)
<asynchronous suspension>

When the exception was thrown, this was the stack:
#0      IntegrationTestWidgetsFlutterBinding.enableTimeline (package:integration_test/integration_test.dart:272:9)
<asynchronous suspension>
#1      IntegrationTestWidgetsFlutterBinding.traceTimeline (package:integration_test/integration_test.dart:302:5)
<asynchronous suspension>
#2      IntegrationTestWidgetsFlutterBinding._runAndGetGCInfo (package:integration_test/integration_test.dart:377:34)
<asynchronous suspension>
#3      IntegrationTestWidgetsFlutterBinding.watchPerformance (package:integration_test/integration_test.dart:432:43)
<asynchronous suspension>
#4      main.<anonymous closure> (file:///Users/bmparr/Development/packages/packages/webview_flutter/webview_flutter_android/example/integration_test/webview_flutter_test.dart:100:5)
<asynchronous suspension>
#5      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:189:15)
<asynchronous suspension>
#6      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1027:5)
<asynchronous suspension>
<asynchronous suspension>
(elided one frame from package:stack_trace)

The test description was:
  withWeakRefenceTo allows encapsulating class to be garbage collected
════════════════════════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Assignees

Labels

fyi-androidFor the attention of Android platform teamfyi-ecosystemFor the attention of Ecosystem teamfyi-toolFor the attention of Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions