Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter_test framework does not run isolates/handle isolate message sending properly #21093

Open
GaryQian opened this issue Aug 28, 2018 · 3 comments
Labels
a: tests "flutter test", flutter_test, or one of our tests dependency: dart Dart team may need to help us found in release: 3.5 Found to occur in 3.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-framework Owned by Framework team triaged-framework Triaged by Framework team

Comments

@GaryQian
Copy link
Contributor

GaryQian commented Aug 28, 2018

Isolates are unable to send and receive messages properly when running flutter_test tests. For example, even very simple ping-pong style messages either fail to send or the isolate may fail to run at all.

import 'dart:isolate';
import 'package:unittest/unittest.dart';

child(args) {
  var msg = args[0];
  var reply = args[1];
  print("msg = $msg, reply = $reply");
  reply.send('re: $msg');
}

void main([args, port]) {
  test('message - reply chain', () {
    ReceivePort port = new ReceivePort();
    port.listen((msg) {
      print("Received msg + $msg");
      port.close();
    });
    Isolate.spawn(child, ['hi', port.sendPort]);
  });
}

This simple example shows one of the symptoms of the issue where the 're: $msg' is never printed.

Other examples sometimes run the child isolate code, but the reply messages to the reply port fails to send.

@GaryQian GaryQian added the a: tests "flutter test", flutter_test, or one of our tests label Aug 28, 2018
@zoechi zoechi added this to the Goals milestone Feb 13, 2019
@zoechi zoechi added the tool Affects the "flutter" command-line tool. See also t: labels. label Feb 13, 2019
@GaryQian
Copy link
Contributor Author

cc @jonahwilliams Not sure if you are the right person to ping on this, but remembered this bug existed!

@jmagman jmagman added this to Awaiting triage in Tools - "flutter test" review Jan 14, 2020
@jonahwilliams jonahwilliams removed the tool Affects the "flutter" command-line tool. See also t: labels. label May 23, 2020
@jonahwilliams jonahwilliams removed this from Awaiting triage in Tools - "flutter test" review May 23, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@iapicca iapicca added dependency: dart Dart team may need to help us framework flutter/packages/flutter repository. See also f: labels. labels Jul 1, 2020
@iapicca
Copy link
Contributor

iapicca commented Jul 22, 2020

Hi @GaryQian
testing the code below with the latest master

code
import 'package:flutter_test/flutter_test.dart';
import 'dart:isolate';

child(args) {
  var msg = args[0];
  var reply = args[1];
  print("msg = $msg, reply = $reply");
  reply.send('re: $msg');
}

void main([args, port]) {
  test('message - reply chain', () {
    ReceivePort port =  ReceivePort();
    port.listen((msg) {
      print("Received msg + $msg");
      port.close();
    });
    Isolate.spawn(child, ['hi', port.sendPort]);
  });
}
logs
 nevercode@Nevercodes-Air  ~/Desktop/projects/master  flutter_master test                                                                                  ✔  2723  14:37:53
00:02 +1: All tests passed!
doctor
[✓] Flutter (Channel master, 1.21.0-2.0.pre.94, on Mac OS X 10.15.5 19F101, locale en-GB)
    • Flutter version 1.21.0-2.0.pre.94 at /Users/nevercode/development/flutter_master
    • Framework revision adc9dde3ba (12 hours ago), 2020-07-21 16:17:23 -0700
    • Engine revision 5a73d4dc25
    • Dart version 2.9.0 (build 2.9.0-21.0.dev 84e5eeaea4)


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/nevercode/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.0

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (4 available)
    • iPhone 11 Pro Max (mobile) • D6967F45-CB0F-4D4E-AFD5-278816A21CAE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • Mac OS X 10.15.5 19F101
    • Web Server (web)           • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 84.0.4147.89

• No issues found!

the issue seems to persist
Thank you

@iapicca iapicca added cp: 1.17 completed found in release: 1.21 Found to occur in 1.21 has reproducible steps The issue has been confirmed reproducible and is ready to work on and removed cp: 1.17 completed labels Jul 22, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@darshankawar
Copy link
Member

This still seems to be the case using latest stable and master versions:

dhs@Dhss-MacBook-Pro test_app % flutter test
00:02 +0: message - reply chain                                                                                                                                                          Shell: msg = hi, reply = SendPort
00:02 +1: message - reply chain                                                                                                                                                          
Received msg + re: hi
00:02 +1: All tests passed!     
stable, master flutter doctor -v

[✓] Flutter (Channel stable, 3.3.5, on macOS 12.2.1 21D62 darwin-x64, locale
    en-GB)
    • Flutter version 3.3.5 on channel stable at
      /Users/dhs/documents/fluttersdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9111f6402 (10 hours ago), 2022-10-19 12:27:13 -0700
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0

[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

[✓] Flutter (Channel master, 3.5.0-6.0.pre.48, on macOS 12.2.1 21D62 darwin-x64,
    locale en-GB)
    • Flutter version 3.5.0-6.0.pre.48 on channel master at
      /Users/dhs/documents/fluttersdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5a7224d14a (7 hours ago), 2022-10-17 12:25:57 +0800
    • Engine revision 59dea4cddd
    • Dart version 2.19.0 (build 2.19.0-312.0.dev)
    • DevTools version 2.18.0
    
[!] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! Flutter recommends a minimum Xcode version of 13.
      Download the latest version or update via the Mac App Store.
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] VS Code (version 1.62.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (5 available)
    • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
    • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
      ios            • iOS 14.4.1 18D61
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
      ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                    •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                                   •
      web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.



@darshankawar darshankawar added found in release: 3.5 Found to occur in 3.5 and removed found in release: 1.21 Found to occur in 1.21 labels Oct 20, 2022
@flutter-triage-bot flutter-triage-bot bot added team-framework Owned by Framework team triaged-framework Triaged by Framework team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: tests "flutter test", flutter_test, or one of our tests dependency: dart Dart team may need to help us found in release: 3.5 Found to occur in 3.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list team-framework Owned by Framework team triaged-framework Triaged by Framework team
Projects
None yet
Development

No branches or pull requests

7 participants