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

Running on flutter-tester: "The requested operation cannot be performed on a file with a user-mapped section open" on Windows #17833

Closed
DanTup opened this issue May 23, 2018 · 22 comments · Fixed by #21137
Labels
e: device-specific Only manifests on certain devices platform-windows Building on or for Windows specifically

Comments

@DanTup
Copy link
Contributor

DanTup commented May 23, 2018

When trying to run with flutter-tester on Windows, I get this error (seems like a file locking issue?):

PS M:\Coding\Applications\Google\flutter\examples\stocks> flutter clean
Deleting 'build\'.
PS M:\Coding\Applications\Google\flutter\examples\stocks> flutter run -d flutter-tester
Launching lib/main.dart on Flutter test device in debug mode...
Syncing files to device Flutter test device...
compiler message: Unhandled exception:
compiler message: FileSystemException: Cannot open file, path = 'build\app.dill' (OS Error: The requested operation cannot be performed on a file with a user-mapped section open.
compiler message: , errno = 1224)
compiler message: #0      _File.open.<anonymous closure> (dart:io/file_impl.dart:354)
compiler message: #1      _RootZone.runUnary (dart:async/zone.dart:1381)
compiler message: #2      _FutureListener.handleValue (dart:async/future_impl.dart:129)
compiler message: #3      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:633)
compiler message: #4      Future._propagateToListeners (dart:async/future_impl.dart:662)
compiler message: #5      Future._completeWithValue (dart:async/future_impl.dart:477)
compiler message: #6      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507)
compiler message: #7      _microtaskLoop (dart:async/schedule_microtask.dart:41)
compiler message: #8      _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
compiler message: #9      _runPendingImmediateCallback (dart:isolate-patch/dart:isolate/isolate_patch.dart:113)
compiler message: #10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:166)

🔥  To hot reload your app on the fly, press "r". To restart the app entirely, press "R".
An Observatory debugger and profiler on Flutter test device is available at: http://127.0.0.1:60220/
For a more detailed help message, press "h". To quit, press "q".

Flutter keeps running (doesn't quit), but pressing r seems to just hang "initialising hot reload" so presumably the app is not running.

@DanTup DanTup changed the title "The requested operation cannot be performed on a file with a user-mapped section open" on Windows Running on flutter-tester: "The requested operation cannot be performed on a file with a user-mapped section open" on Windows May 23, 2018
@DanTup
Copy link
Contributor Author

DanTup commented May 23, 2018

@scheglov Have you seen this one? I thought it was intermittent, but right now I'm seeing it 100% of the time (both locally on my machine and on Travis).

DanTup added a commit to Dart-Code/Dart-Code that referenced this issue May 23, 2018
@devoncarew
Copy link
Member

@aam, Danny is seeing this frequently on windows. Perhaps a race condition with access to the dill file within flutter_tools?

@aam
Copy link
Member

aam commented May 24, 2018

Isn't this related to the question asked on this PR flutter/flutter-intellij#2239 (comment) ?

@DanTup
Copy link
Contributor Author

DanTup commented May 24, 2018

Yep, the discussion in that PR seems to describe the same issue.

@DanTup
Copy link
Contributor Author

DanTup commented Jun 13, 2018

I've got a some reasonable end-to-end hot reload tests working in Dart Code now (launches an app, adds breakpoints, hot reloads a few times, ensures reloads are working and we're still hitting breakpoints) but this is blocking me from running them on Windows CI (I have to switch to my PC and run them on against a real device for testing). It would be tremendously useful having these tests running all the time so if there's anything I could to do assist with/investigate/workaround this, let me know!

@DanTup
Copy link
Contributor Author

DanTup commented Jun 18, 2018

There's a failing test in flutter_tools for this in #18560.

DanTup added a commit that referenced this issue Jun 27, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Jul 2, 2018

@aam Do you know what the status of this is (or there's a workaround)? It's not clear from the discussion in the PR linked above if we know what the fix will be.

@aam
Copy link
Member

aam commented Jul 2, 2018

The .dill-file being locked for the duration of flutter run seems to be by design per comment I linked above. Am I right reading this as we are trying to update .dill-file while flutter is running? What are we trying to achieve with this?

@DanTup
Copy link
Contributor Author

DanTup commented Jul 2, 2018

I think the case mentioned by @scheglov in the PR (for preview) may be more complicated, but in this case I'm doing nothing more than trying to run the app on flutter-tester. I just run flutter run -d flutter-tester and it'll spit out this error (on Windows). I'm able to do the same thing on macOS and Linux with no issues.

@aam
Copy link
Member

aam commented Jul 2, 2018

I see, I'm not familiar with what is involved in running on flutter-tester device. @scheglov who put it together might be the best person to comment on that.

@scheglov
Copy link
Contributor

scheglov commented Jul 3, 2018

I saw this problem on Windows as well.

@DanTup DanTup added e: device-specific Only manifests on certain devices platform-windows Building on or for Windows specifically labels Jul 4, 2018
@DanTup
Copy link
Contributor Author

DanTup commented Jul 4, 2018

I'm not really sure where this issue lies or who can progress it. Here's the stack where the compiler is being invoked when it's spitting out this error. I'm not sure whether it's wrong that file is already locked at this stage, or whether it shouldn't be trying to compile.

windows error

@aam
Copy link
Member

aam commented Aug 28, 2018

I just realized that this problem is caused by the fact that dart vm was requested to load exact same kernel file, that compiler is trying to update - same /tmp/flutter_hot_reload_test_app.*/build/app.dill goes to the vm and incremental compiler overwrites it as it initializes itself to serve hot reload. This is rather dangerous, on any platform. It seems good that Windows actually prevents you from doing that.
Under normal conditions vm runs on the device, compiler runs on the host and compiler never overwrites files that vm is loading.

So the issue seems to be with how FlutterTesterDevice is set up.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 28, 2018

Aha, makes sense. Does the fix need to go into the flutter_tester binary, or just in the Dart FlutterTestDevice class we have that wraps it?

@aam
Copy link
Member

aam commented Aug 28, 2018

Does the fix need to go into the flutter_tester binary, or just in the Dart FlutterTestDevice class we have that wraps it?

FlutterTestDevice I think.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 29, 2018

Woo! Thanks for this - looks obvious now seeing the fix! I'll give this a test and hopefully unskip the integration tests shortly. Thanks!

@aam
Copy link
Member

aam commented Aug 29, 2018

No worries. From what I've seen we do need to fix path/uri handling in VM service layer for the tests to pass - currently file path that is passed on reload request gets interpreted as unix(rather than windows) file path and that causes issues in VM.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 29, 2018

Is there any issue open about them? I can try the tests and update the comments with the new issues to make it easier to track. I know about #18441 but that one only affects one test. There are some that don't reload at all, so if the issue is only during reload, maybe we can still unskip them. I'll do some testing.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 29, 2018

I guess this is the issue you're referring to:

[{"event":"app.progress",
  "params":{"appId":"e941bdfc-7147-476f-bde2-5b9a78041d93","id":"2","progressId":null,"finished":true}}]
error: Unable to read Dart source
  '/C:/Users/danny/AppData/Local/Temp/flutter_expression_test.d5449878-ab60-11e8-ac4e-001a7dda7113dc576365-ab60-11e8-ac4e-001a7dda7113/flutter_expression_test.d5449878-ab60-11e8-ac4e-001a7dda7113/lib/main.dart.incremental.dill'.
e:\b\build\slave\windows_engine\build\src\third_party\dart\runtime\vm\os_thread.cc: 73:
  error: Thread exited without calling Dart_ExitIsolate
Dumping native stack trace for thread c90
Lost connection to device.

LMK if you want me to open an issue for this (I can't see an existing one).

@aam
Copy link
Member

aam commented Aug 29, 2018

LMK if you want me to open an issue for this (I can't see an existing one).

Sure, if you have time to open an issue, that would be handy. Thanks.

@DanTup
Copy link
Contributor Author

DanTup commented Aug 29, 2018

I've opened #21168. If you need any more specific info, let me know!

@github-actions
Copy link

github-actions bot commented Sep 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: device-specific Only manifests on certain devices platform-windows Building on or for Windows specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants