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

Default FG color displays as BG color on some lines #1342

Closed
clytras opened this Issue Dec 2, 2017 · 24 comments

Comments

Projects
None yet
3 participants
@clytras
Copy link

clytras commented Dec 2, 2017

Versions

ConEmu build: 171117 [64] {Alpha} x64
OS version: Windows 10 x64
Used shell version: cmd (Admin)

Problem description

Some lines display with same FG color as BG color when running react-native. I got this problem just today when updated to the latest Alpha version. I had an older ConEmu version before that and it worked fine. Also it works as expected when using Windows cmd. The FB color should have print is the WHITE (Code 7), but when I copy ANSI sequences, I see that the ConEmu has BLACK escape character for the FG color:

Copied ANSI sequences

I tried to delete settings file, different color profiles, reinstalling the same version again.

Steps to reproduce

  1. Open ComEnu cmd
  2. Navigate to a react-native project
  3. Execute react-native run-android on an initialized project

Actual results

Some text having FG color white, display like FG color black:
Hidden Text

Expected results

These lines should print with the default WHITE FG color like in the Windows cmd:
Normal Text

Additional files

I just noticed that it prints the first line using FG WHITE when scrolling:
First Line Normal

Settings,
Dump screen file

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 2, 2017

Comparison is not fair. Show the RealConsole from the moment when some text is not visible and compare there.

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 4, 2017

I opened RealConsole and the result is same there. The text is hidden, here is a screenshot; it's the small black window, not the big one which is the Windows cmd console (can't get it bigger, it ignores my resize attempts):

RealConsole

What does that means? Is this a configuration issue or something?
Is there a way (other than re-installing, deleting ConEmu.xls) to reset the ConEmu settings so make it behave and look like the default Windows cmd?

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 4, 2017

ConEmu shows what console application tells to it.
If your application (react-native) has branches in code due to ANSI detection, this may be a bug in this application but not in ConEmu.

Turn on ANSI logging, start new console (tab), repeat your command and upload here link to generated log file.

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 4, 2017

Here is the log file: ConEmu-2017-12-04-p47860.log

I just tried and disabled Settings > Features > Inject ConEmuHk and it worked. It runs and displays the node scripts the same like in cmd Windows.

ConEmuHk Disabled

I also have cygwin, cygwin64 and MinGW, mingw-w64 both installed, and maybe that is related to this problem? I am not running any of those shells though when facing the problem, just cmd or cmd (Admin).

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 4, 2017

Your link is not working. Please use gist instead.

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 4, 2017

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 4, 2017

In the log I don't see ANSI sequences before UP-TO-DATE, so react is using WinApi (it's not logged).
I need more thorough steps to reproduce, I'm not a react user.

JFI

> ping zikro.gr
Ping request could not find host zikro.gr. Please check the name and try again.
@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 4, 2017

Yes I believe you, I guess there are some DNS issues with that domain, if you check it here you'll see it says it's OK.

Anyway, can you please tell me how can I get the right ANSI sequence log file?
Here is what I get when I copy the ANSI sequence and I paste it into a gist: https://gist.github.com/clytras/c0d97bbc3bb6d47a36d0ed264e3eece7

There are ANSI escape characters but that is what ConEmu prints out as well.

Isn't it strange that it was working with an older version (can't remember what versions that was) and it also works if I disable the Inject ConEmuHk feature?

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 4, 2017

In your last log there are following lines

[30m�[40m:app:installDebug �[33m�[40mFAILED�

That means black on black for ":app:installDebug", isn't it?

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 4, 2017

Yes that is correct, black to black, but that is what is printed, maybe it's not what actually cmd got. After some investigation, I can see that the whole problematic output comes out from Gradle automation tool build with Java.

If you look at these screenshots, you'll that there is some text:

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

ConEmu_text_shown

which all the text is hidden, but only the arguments (--stacktrace, --info, --debug) are visible:

ConEmu_text_hidden

and if you go at BuildExceptionReporter.java:191 on Github, you'll see that there is a style option UserInput for the arguments and the rest of the text is handled just with a text function for Normal text output.

That makes me think that maybe there is an issue with how Gradle handles the ANSI text formating and maybe there is a bug, but again I am not so sure since it outputs as normal in Windows cmd console and even in ConEmu when not using the ConEmuHk injection.

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 5, 2017

As I said, if application determines ANSI capable terminal, it uses ANSI, if not (no ConEmu) - it switches to another code brunch and uses WinApi. Report to authors buggy ANSI output.

If you disable ConEmuHk don't you see these unprocessed ANSI sequences? I didn't understand you.

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 5, 2017

What is exactly that you don't understand? Please read again this comment above, that has even a screenshot inside that shows how ConEmu displays the output when I have the ConEmuHk injection disabled. It displays everything normal like Windows cmd does.

I don't have any more time to investigate this. If you think this is not a ConEmu bug, then we just close it and continue. My problem is solved by disabling ConEmuHk feature, I am not really sure what extra features I'll miss by disabling that though.

@clytras clytras closed this Dec 5, 2017

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 5, 2017

What is exactly that you don't understand?

Simple thing. If your first log #1342 (comment) there are no ANSI in the line with :app:preReleaseBuild UP-TO-DATE. Absolutely. But there are ANSI above (cmd prompt and line with Running C:\Dev\Android\sdk/platform-tools/adb).
In your second comment #1342 (comment) there are ANSI codes in the line �[30m�[40m:app:preReleaseBuild �[33m�[40mUP-TO-DATE�[37m�[40m. And these codes are produced not by ConEmu but by your console tool, aren't they?
I don't know what was the difference in your settings between these two logs. That is what I don't understand.

If you think this is not a ConEmu bug

Of course. �[30m�[40m means black on black and that what ConEmu displays to you. Do you agree that this code is produced by react-native? I hope so, it's obvious. ConEmu must not change output produced by console applications, thats why you see black text on black background.

I told you several times, that it's upon react-native to decide which API they use: ANSI or WinAPI. ConEmu has no control over it.

And instead of reporting the problem with their ANSI to react-native authors you decided to disable major part of ConEmu features. Well, it's your decision.

https://conemu.github.io/en/ConEmuHk.html

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 6, 2017

No I do not agree that this code is produced by react-native. That is something you are saying. If it does then why it displays fine in the Windows cmd console? And even in ConEmu without the Hk injection? If react-native would print black text on black background, then it would display the text line like that in Windows cmd console even. Can you understand that? Do you understand that this is working as expected when I disable that Hk feature in ConEmu settings? Thanks for your time though, I just wanted to help.

EDIT

You are acting like Facebook's react-native is a script that some guy wrote and executes some commands. If you check it here https://github.com/facebook/react-native, you will realize that it is very popular with 56,000 stars and 13,000 forks. Do you really believe that a project so popular like that with Facebook developers behind it would have such silly bugs when using it's main functionality, to build the Android application? I will try and report a bug there when I find some time. You know maybe there is no issue with react-native neither with ConEmu, but that requires some investigation.

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 6, 2017

Seems lime you just don't hear me.

  1. Who prints ANSI codes? Don't you think it's the ConEmu?
  2. These ANSI codes tells ConEmu to use black on black. Aren't they?

Please tell me do you accept these assertions or want to argue them?

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 6, 2017

I am still waiting you to answer my questions.

When the cmd.exe prints, doesn't it get ANSI code sequences? Why does it print without a problem?

When ConEmu prints without the Hk injection, doesn't it use ANSI code sequences? Why does it print without any issues?

Here we have a behavior that DOES NOT occur when a specific feature turns OFF, and that is ConEmuHk injection. Why do you insist to ignore that fact?

So, here are the ANSI codes with the Hk injection disabled: https://gist.github.com/clytras/84419fb838c0b6e4824163a5f9788637

As you can see, there is 37 Foreground and 40 for Background colors which is white text on black background. How do you explain that? If you insist that this is what ConEmu gets from react-native, then why does ConEmu gets some properly escapes ANSI sequences when it has that feature disabled?

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 6, 2017

I am still waiting you to answer my questions

And you ignore mine questions.

When the cmd.exe prints, doesn't it get ANSI code sequences?

Why do you think it does? Did you check that? Did you seen them? Again. The application may use WinAPI instead of ANSI. Only authors or debugger may say what happens there.

When ConEmu prints without the Hk injection, doesn't it use ANSI code sequences? Why does it print without any issues?

So, here are the ANSI codes with the Hk injection disabled

What? Where did you take these ANSI codes??? If you disable ConEmuHk, you ConEmu ANSI logging is not working. Sorry, but your assertions doesn't look reliable.
If you see these codes in the console you can't insist that there are no issues.

As you can see, there is 37 Foreground and 40 for Background colors which is white text on black background. How do you explain that?

Do you insist that ConEmu CHANGES the data console application prints? Do you really believe I specially make you life harder by changing correct 37 to wrong 30? ConEmu is open source, you may easily check my code.

Read this article, you may find it interesting

https://conemu.github.io/en/ThirdPartyProblems.html

@clytras

This comment has been minimized.

Copy link
Author

clytras commented Dec 7, 2017

Which questions exactly I ignore of yours? Check all the above replies and you'll find your answers.

Who prints ANSI codes? Don't you think it's the ConEmu?

Of course react-native does. Not even I told you that, but I found the very source code that does that and through what library, check the above comment here. I told you there that react-native uses the Gradle automation library and here at BuildExceptionReporter.java line 191 you will see the example that I described.

These ANSI codes tells ConEmu to use black on black. Aren't they?

Once again I will tell you that this is not true, because if that would be true, then that would be the case even for cmd Windows and ConEmu with Hk injection. How many times do I have to write that thing? How many?

Why do you think it does? Did you check that? Did you seen them? Again. The application may use WinAPI instead of ANSI. Only authors or debugger may say what happens there.

Yes I can see them, because I am a developer with plenty of knowledge an I found the way that react-native outputs the commands. I told you where to look even. Go check at the Gradle project and you'll see for yourself. It does not uses WinAPI, you can see that if you check that library and EVEN if it does, how do you think WinAPI SetConsoleTextAttribute does print the console attributes? If you guess by ANSI sequences, you will guess right.

What? Where did you take these ANSI codes??? If you disable ConEmuHk, you ConEmu ANSI logging is not working. Sorry, but your assertions doesn't look reliable.
If you see these codes in the console you can't insist that there are no issues.

You don't believe me now? Where did I get the correct ANSI sequences (???), from ConEmu of course. menu Edit > ANSI sequences checked and the menu Edit > Copy All and paste to a gist. This is a copy of ConEmu ANSI sequences. You insist that ConEmu has no issue here when you can see that it gets correct ANSI sequences without that Hk feature... How do you explain that? I am still waiting for an answer other than "only the developers know how they echo by WinAPI or ANSI sequences" which is a same thing done with 2 different methods.

Do you insist that ConEmu CHANGES the data console application prints? Do you really believe I specially make you life harder by changing correct 37 to wrong 30? ConEmu is open source, you may easily check my code.

Yes, there is something that changes those ANSI sequences when the Hk injection is enabled. You still question that fact? I attached the gist with black text on black background, please don't do that and tell me I do such things... Where did I accused you did something like that?

Still waiting an answer why it works without Hk injection and why it does not with it enabled.

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 7, 2017

Still waiting an answer why it works without Hk injection and why it does not with it enabled.

So I need to dig the react-native and gradle projects, examine their codes, learn how to debug them and try to understand why they push 30 instead of 37? How do you estimite the time I need to pay to create a possible PR to these projects?

BTW, you issue has something in common with yarnpkg/yarn#2724

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 7, 2017

Once again I will tell you that this is not true, because if that would be true, then that would be the case even for cmd Windows and ConEmu with Hk injection. How many times do I have to write that thing?

How many times I have to write that application or library may (and often has) different branches of the code (if else statement). And the code for ConEmu may be different! Why this statement is so hard to understand?

The same was with Docker and well, I spent my personal time to create a PR to the DOCKER!

Yes I can see them, because I am a developer with plenty of knowledge

So you may easily set a breakpoint in the ConEmu code at functions CEAnsi::OurWriteConsoleA or CEAnsi::OurWriteConsoleW to ensure that ConEmuHk doesn't do any magic changing 37 to 30.

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 7, 2017

Assume some application works in Windows 7 but crashes in Windows 10. What would you do? Report to Microsoft that Windows 10 is broken or tell the application authors that they have problems with Win10? What report would have the effect?

Well, I don't insist that ConEmu is completely bugless, but your issue let me think that something in the react-native or its libraries works in unexpected way in ConEmu. And their authors have much much more chances to understand what! They known how their product works, but not me.

@foal

This comment has been minimized.

Copy link

foal commented Dec 7, 2017

You don't believe me now? Where did I get the correct ANSI sequences (???), from ConEmu of course. menu Edit > ANSI sequences checked and the menu Edit > Copy All and paste to a gist.

To be clear. Then you did it (Copy All) the ConEmu converted the screen colors to ANSI sequences. It does not mean that the colors on the screen were generated with ANSI sequences.

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 7, 2017

To be clear. Then you did it (Copy All) the ConEmu converted

That is a total surprise. I asked to to make ANSI logs via ConEmu interface, to get REAL ANSI output from your console application.
So I can't trust any logs you attached before because they are just representation of ALREADY PRINTED data. That was not I asked for.

But I asked to to get RAW ANSI codes to check if there is something wrong!!!

Moreover, I asked to to create a step-by-step guide to reproduce your problem. Where is it? I need to learn manuals how to create the app, how to configure it, how to run it?

@Maximus5

This comment has been minimized.

Copy link
Owner

Maximus5 commented Dec 8, 2017

I'm afraid I will surprise you.

  1. Do you know what is react-native? Yep, it's a js script executed by node.
  2. Do you know what is node.exe? Yep, it's a Windows executable.
  3. What would you see, if you run dumpbin /imports:kernel32.dll node.exe?

Surprise: 20 functions from Windows console API. Do you still think it prints ANSI codes to ConOut?

FillConsoleOutputAttribute
FillConsoleOutputCharacterW
FlushConsoleInputBuffer
GetConsoleCP
GetConsoleCursorInfo
GetConsoleMode
GetConsoleScreenBufferInfo
GetConsoleTitleW
GetNumberOfConsoleInputEvents
ReadConsoleInputA
ReadConsoleInputW
ReadConsoleW
SetConsoleCtrlHandler
SetConsoleCursorInfo
SetConsoleCursorPosition
SetConsoleMode
SetConsoleTextAttribute
SetConsoleTitleW
WriteConsoleInputW
WriteConsoleW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment