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

Please provide a way to set untranslated I/O mode on Windows #55393

Closed
projektorius96 opened this issue Apr 6, 2024 · 6 comments
Closed

Please provide a way to set untranslated I/O mode on Windows #55393

projektorius96 opened this issue Apr 6, 2024 · 6 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug

Comments

@projektorius96
Copy link

projektorius96 commented Apr 6, 2024

So I am writing a Native messaging host for Chromium-based browser in Dart, I have a working draft of transcoding implementation and it works for decodeMessage (at least I can see that on my side with stdout redirected to file), but it seems that it breaks on dart_io.stdout.write call, and not because of encodeMessage implementation itself, but due to default (i.e. _O_TEXT) Windows's I/O translation mode, which in turn corrupts the encoded message with the respond from Chromium-based browser Extension system Error when communicating with the native messaging host.

I am writing this to to request a feature, which as far as I do understand does not currently (2024 Q1) exist on higher level end of Dart VM, i.e. to control the I/O mode for Windows via Dart VM . Please understand that FFI to C via Win API is my last resort.

P.S. I am willing to share the final codebase with Dart community once I get it done working

Thank you.


This tracker is for issues related to:

  • Dart core libraries
  • Dart native compilers
  • Dart VM
@vsmenon vsmenon added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label Apr 8, 2024
@projektorius96
Copy link
Author

Windows users only!

Consider the following alternative instead of Native Messaging Host – the motivation of using this, could be a simpler set up and no registry involved.

Cheers ! ♥

@a-siva a-siva added the type-enhancement A request for a change that isn't a bug label Apr 10, 2024
@brianquinlan brianquinlan added the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Apr 10, 2024
@brianquinlan
Copy link
Contributor

@projektorius96 I don't understand your issue; stdout.write does not do new line translation by default (in Dart 3.4, you will be able to control that behavior with the lineTerminator field.

Do you have a minimal example that demonstrates the issue?

@projektorius96
Copy link
Author

projektorius96 commented Apr 10, 2024

@projektorius96 I don't understand your issue; stdout.write does not do new line translation by default (in Dart 3.4, you will be able to control that behavior with the lineTerminator field.

Do you have a minimal example that demonstrates the issue?

Well, first of all REAMDE.md provides a quick insight how to do repro on local machine, well I guess you know better than me how to glue up things for sure.

To follow up, I have couple of arbitrarily defined functions as per implementation :

  • decodeMessage works just fine, stream redirection to file shows exactly same message sent from service-worker via sendNativeMessage source
  • encodeMessage somehow corrupts a message and I naturally suspected the I/O translation mode keeping in mind it is documented in Debugging as described per original post; After all, it can be something wrong with encodeMessage itself, but in that case, I'd say Chromium is really nit-picky if it cannot pick up even broken message, rather than giving me the aforementioned error as follows "Error when communicating with the native messaging host." .

Finally, I just wanted to say it is my very first try doing something relatively low, but in higher programming language, and I even fail at that. It simply can be something wrong with my codebase due to lack of knowledge. However, I wrote an alternative solution based on WebSocket to communicate between the Dart host and Service Worker, I'd say I even prefer the later one, yet I was interested into implementing former one too. Curiosity is a powerful weapon, but like I said I am failing with native messaging host at this stage.

Cheers !

@github-actions github-actions bot removed the needs-info We need additional information from the issue author (auto-closed after 14 days if no response) label Apr 11, 2024
@brianquinlan
Copy link
Contributor

Hi @projektorius96

I'm going to close this issue. If you manage to reduce this enough to demonstrate a bug in dart:io, please reopen it!

@projektorius96
Copy link
Author

projektorius96 commented Apr 17, 2024

@brianquinlan so apparently I have to admit I was wrong, I mean well like I said "lack of knowledge", if you ever eyeballed on my codebase, you perhaps you had said that I need to await stdout.flush(), but nah it took me couple of yours to figure out it by myself, perhaps ill-service would not serve me for better as developer, yet I was expecting a bit of the help out here and got none. Crocodile tears 🤔

@projektorius96
Copy link
Author

If interested, you can follow up the related discussion on this issue. I am closing this myself, if you have anything to add, please re-open.

Cheers !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants