• liyuqian's avatar
    Fix flaky peer connection (#36089) · 180aa0c0
    liyuqian authored
    Fixes https://github.com/flutter/flutter/issues/36091.
    
    Previously, a sendRequest will be sent even if the peer is closed during
    a driver test. That will cause a time out without any error information.
    Such issue is unreproducible on my Mac Book Pro, but 100% reproducible
    on our new Mac mini (2018).
    
    The closing issue is tracked in https://github.com/flutter/flutter/issues/36268
    
    Additional to this fix, we should also patch the jason_rpc_2 so the peer
    will throw exception if sendRequest is attempted while the connection is
    closed.
    
    **Test**:
    tiles_scroll_perf_iphonexs__timeline_summary failed without this patch.
    It will pass after this patch.
    
    I'm not sure how to add a unit test for this. Please let me know if you have
    some ideas.
    
    This patch will generate the following warning log on the new Mac Mini
    ```
    flutter: Observatory listening on http://127.0.0.1:50192/cZPDF4sW7MM=/  
    Installing and launching...                                        10.2s
    00:00 +0: scrolling performance test (setUpAll)
    [info ] FlutterDriver: Connecting to Flutter application at http://127.0.0.1:1069/cZPDF4sW7MM=/
    [trace] FlutterDriver: Isolate found with number: 3684677742843303
    [trace] FlutterDriver: Isolate is paused at start.
    [trace] FlutterDriver: Attempting to resume isolate
    [trace] FlutterDriver: Waiting for service extension
    [info ] FlutterDriver: Connected to Flutter application.
    00:00 +0: scrolling performance test complex_layout_scroll_perf
    [warning] FlutterDriver: Instance of '_WebSocketImpl' is closed with an unexpected code 1005
    [warning] FlutterDriver: Peer connection is closed! Trying to restore the connection...
    00:10 +1: scrolling performance test tiles_scroll_perf
    [warning] FlutterDriver: Instance of '_WebSocketImpl' is closed with an unexpected code 1005
    [warning] FlutterDriver: Peer connection is closed! Trying to restore the connection...
    00:20 +2: scrolling performance test (tearDownAll)
    00:20 +2: All tests passed!
    Stopping application instance.
    ```
    180aa0c0
Name
Last commit
Last update
..
flutter Loading commit data...
flutter_driver Loading commit data...
flutter_goldens Loading commit data...
flutter_goldens_client Loading commit data...
flutter_localizations Loading commit data...
flutter_test Loading commit data...
flutter_tools Loading commit data...
fuchsia_remote_debug_protocol Loading commit data...
analysis_options.yaml Loading commit data...