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

[Console] ProgressBar behavior (question) #13019

Closed
llaville opened this Issue Dec 17, 2014 · 12 comments

Comments

Projects
None yet
10 participants
@llaville

llaville commented Dec 17, 2014

Platform: Windows with ANSICON 1.66 installed

My Windows Console 2.00.148 is configured with 120 char width and 32 lines

I've migrated recently from ProgressHelper to ProgressBar with Symfony Component 2.6.1, and I've a question about the new progress bar behavior.

When full win console is reached, the progress bar (even with ANSI support) changed from a one line display to a multi lines display.

Here are what I got when the full win/console width is not yet reached. A one line display that is refreshed at each changes


3 [--->------------------------]  1 sec 7.0 MiB File Reflect\Analyser\CompatibilityAnalyser.php in progress...

And after the full win/console width is reached (in my case : 120 char) at step 52


52 [------------------------>---] 13 secs 12.5 MiB File Reflect\Plugin\Cache\CacheAdapterInterface.php in progress...
53 [------------------------->--] 13 secs 12.5 MiB File Reflect\Plugin\Cache\CacheStorageInterface.php in progress...
54 [-------------------------->-] 13 secs 12.5 MiB File Reflect\Plugin\Cache\DefaultCacheStorage.php in progress...
55 [--------------------------->] 13 secs 12.5 MiB File Reflect\Plugin\Cache\DoctrineCacheAdapter.php in progress...
56 [>---------------------------] 14 secs 12.5 MiB File Reflect\Plugin\CachePlugin.php in progress...
57 [->--------------------------] 14 secs 12.5 MiB File Reflect\Plugin\Log\DefaultLogger.php in progress...
58 [-->-------------------------] 14 secs 12.5 MiB File Reflect\Plugin\LogPlugin.php in progress...
59 [--->------------------------] 14 secs 12.0 MiB File Reflect\Plugin\PlantUML\PlantUMLPlugin.php in progress...
60 [---->-----------------------] 15 secs 12.0 MiB File Reflect\Plugin\PluginInterface.php in progress...
61 [----->----------------------] 15 secs 11.8 MiB File Reflect\Plugin\PluginManager.php in progress...
62 [------>---------------------] 15 secs 11.8 MiB File Reflect\Plugin\ProfilerPlugin.php in progress...
63 [------->--------------------] 16 secs 11.8 MiB File Reflect\Printer\Text.php in progress...
64 [-------->-------------------] 16 secs 11.8 MiB File Reflect\Tokenizer\DefaultTokenizer.php in progress...
65 [--------->------------------] 16 secs 11.8 MiB File Reflect.php in progress...
65 [============================] 16 secs 11.8 MiB File Reflect.php in progress...

Is it supposed to be the standard ProgressBar behavior, or just a bug ?

@stof

This comment has been minimized.

Member

stof commented Dec 17, 2014

this looks like a bug

@javiereguiluz

This comment has been minimized.

Member

javiereguiluz commented Dec 19, 2014

In my case, this problem occurs when the console window width is shorter than the progress bar width. This compares the same Symfony Installer use with different console windows:

It works OK

works_ok

It doesn't work OK

does_not_work_ok

@javiereguiluz

This comment has been minimized.

Member

javiereguiluz commented Mar 26, 2015

Is anyone willing to take a look at this annoying issue before 2.7 freezes in a few days?

@sstok

This comment has been minimized.

Contributor

sstok commented Mar 26, 2015

The line length seems to be messed-up because its wrapped by the console. The overwrite() method determines the length by splitting the lines, but as the line is split by the console you get an extra "\n" and thus a wrong result.

Because it does remove some chars, just not enough.

======================================>-
    4.78 MB/4.90 MB ====================
======================================>-
    4.80 MB/4.90 MB ====================
======================================>-
    4.81 MB/4.90 MB ====================

But I can't think of anything to fix this :(

Edit. This is getting interesting https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Console/Helper/ProgressBar.php#L514 this moves the cursor up, then everything you write overwrites whats already there :|

But as the lines are wrapped the number of lines increases, so we need to detect if the console width is lower then the line length. If so compensate for this. But how.

@javiereguiluz

This comment has been minimized.

Member

javiereguiluz commented Mar 26, 2015

@sstok thanks for investigating the issue. Let's see if we can find a solution somehow.

@wouterj

This comment has been minimized.

Member

wouterj commented Mar 27, 2015

@javiereguiluz freeze is only for features, after it there are some months to fix bugs, finish docs, etc.

@llaville

This comment has been minimized.

llaville commented Oct 8, 2015

Is there any fresh news about a fix for this issue ?

@llaville

This comment has been minimized.

llaville commented Oct 28, 2015

No changes since a long time about this issue ! Should I consider to close it ?

@jakzal

This comment has been minimized.

Member

jakzal commented Oct 28, 2015

@llaville I think it's worth to try to solve it before we close.

@TomasVotruba

This comment has been minimized.

Contributor

TomasVotruba commented Oct 31, 2015

Do you propose any solutions? I might look on it.

Should it be adjusted to the width of the window?

@xabbuh

This comment has been minimized.

Member

xabbuh commented Nov 1, 2015

@TomasVotruba If possible, the progress bar should indeed limit itself to the width of the window if that is less than what would have been used otherwise.

fabpot added a commit that referenced this issue Jun 17, 2016

feature #19012 [Console] progress bar fix (TomasVotruba, fabpot)
This PR was merged into the 3.2-dev branch.

Discussion
----------

[Console] progress bar fix

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13019
| License       | MIT
| Doc PR        | -

This is #16490 where I've simplified the code as much as possible and added a test for the bug we're trying to fix.

The main change is the renaming of the `TerminalDimensionsProvider` to just `Terminal`. The new class can probably be useful to add more about the terminal.

Commits
-------

2f81247 switched to use COLUMNS and LINES env vars to change terminal dimensions
bf7a5c5 fixed logic
a589635 deprecated some Console Application methods
8f206c8 fixed CS, simplified code
b030c24 [Console] ProgressBar - adjust to the window width (static)

@fabpot fabpot closed this Jun 17, 2016

@bamarni

This comment has been minimized.

Contributor

bamarni commented Sep 17, 2017

With the latest symfony installer, I'm still getting the display issue highlighted by @javiereguiluz here :

screenshot from 2017-09-17 17-32-00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment