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

Serial Monitor does not Autoscroll on new content received when view is not in focus #1724

Closed
3 tasks done
Defragster opened this issue Dec 1, 2022 · 8 comments · Fixed by #1928
Closed
3 tasks done
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project

Comments

@Defragster
Copy link

Defragster commented Dec 1, 2022

Describe the problem

Serial Monitor view does not autoscroll on new content received when the view is not in focus.

To reproduce

Equipment

Any Arduino board that can print to Serial Monitor.

Steps

  1. Create a sketch that prints to Serial Monitor soon after the program starts:
    void setup() {
      Serial.begin(9600);
      for (byte counter = 0; counter < 100; counter++) {
        Serial.println("hello");
      }
    }
    void loop() {}
  2. Press the Ctrl+Shift+P keyboard shortcut (Command+Shift+P for macOS users) to open the "Command Palette".
  3. Select the "Toggle Output View" command from the menu.
    This step is only required if the "Output" view was not already open. That condition will be met as a matter of course during normal usage of Arduino IDE so the bug is not specific to the use of the "Toggle Output View" command.
  4. Connect the Arduino board to your computer.
  5. Select the board and port in Arduino IDE.
  6. Open the "Serial Monitor" view if it is not already open.
  7. Select "9600 baud" from the dropdown baud rate menu at the top right corner of the "Serial Monitor" view.
  8. If it is not already enabled, click the "Toggle Autoscroll" icon near the top left corner of the "Serial Monitor" view to enable autoscroll.
  9. Click the "Clear Output" icon at the top left corner of the "Serial Monitor" view.
  10. Select Sketch > Upload from the Arduino IDE menus.
  11. Wait for the upload to finish successfully.
  12. Select the "Serial Monitor" tab in the bottom panel.
    🐛 The printed text is not visible in the "Serial Monitor" view:
    image
  13. Scroll the output field of the "Serial Monitor" view downward.
    You will now see the printed text.
  14. Click the "Clear Output" icon at the top left corner of the "Serial Monitor" view.
  15. Create a sketch that prints to Serial Monitor after a delay:
    void setup() {
      Serial.begin(9600);
      delay(10000);
      for (byte counter = 0; counter < 100; counter++) {
        Serial.println("world");
      }
    }
    void loop() {}
  16. Select Sketch > Upload from the Arduino IDE menus.
  17. Wait for the upload to finish successfully.
  18. Immediately select the "Serial Monitor" tab in the bottom panel.
    The reason for the "immediately" instruction is to ensure the "Serial Monitor" view will have focus by the time the sketch program starts printing.
  19. Wait until the sketch program's 10 s delay has passed.
    🙂 Serial output from the board is visible in the "Serial Monitor" view.
    ❗ The scroll is incomplete due to a separate bug: Serial Monitor scroll is incomplete when autoscroll is enabled #1736

Expected behavior

All buffered output should be visibly displayed in Serial Monitor tab.

Arduino IDE version

Original report

2.0.2

Last verified with

01ee045

Operating system

Windows

Operating system version

windows 11

Additional context

Originally reported at https://forum.pjrc.com/threads/71588-Arduino-IDE2-Serial-Monitor-sometimes-does-not-work-continue-from-Upload-Thread?p=316565

Additional reports:

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the latest nightly build
  • My report contains all necessary details
@Defragster Defragster added the type: imperfection Perceived defect in any part of project label Dec 1, 2022
@Defragster Defragster changed the title IDE SerMon fails to UGI draw initial text output IDE SerMon fails to GUI draw initial text output Dec 1, 2022
@Defragster
Copy link
Author

See https://forum.arduino.cc/t/ide-2-0-2-serial-monitor-data-forgets-to-scroll-with-new-data/1060247 and https://forum.pjrc.com/threads/71588-Arduino-IDE2-Serial-Monitor-sometimes-does-not-work-continue-from-Upload-Thread?p=316574&viewfull=1#post316574

As posted above, AutoScroll was ON and that was not noted as problem. Focus above was failure to draw 'top lines', but those are OLD lines and new data below should have scrolled up and did not.

So seems this should have been the real focus of this issue. Will change the title.

@Defragster Defragster changed the title IDE SerMon fails to GUI draw initial text output IDE SerMon fails to GUI AutoScroll on new content received when not 'in focus' Dec 1, 2022
@PaulStoffregen
Copy link

PaulStoffregen commented Dec 2, 2022

Shared this video demo on the forum threads, might as well have it linked here too.

https://www.youtube.com/watch?v=oHIKPysz9dI

demo video

Problem not limited to Teensy, also happens with Arduino Leonardo.

@per1234 per1234 changed the title IDE SerMon fails to GUI AutoScroll on new content received when not 'in focus' Serial Monitor does not Autoscroll on new content received when view is not in focus Dec 4, 2022
@per1234 per1234 added the topic: code Related to content of the project itself label Dec 4, 2022
@Defragster
Copy link
Author

Defragster commented Dec 5, 2022

Updated to IDE 2.0.3 and the Blank/Clipped issue seems gone as the initial 'window' of text is now visible. At least this is the case with Updated PJRC Teensy Serial Monitor code.

The IDE Serial Port Monitor code however once repeated the 'BLANK' window? Now is showing initial sketch output?

However, there is a problem with AutoScroll: It scrolls for initial output from setup() - but stops there as additional output arrives it never moves to the scrolled bottom newest text?

Code below prints an "A=" section then a "B=" section, it scrolls to "A=" then stops leaving the following "B=" portion offscreen.

This can also be seen in that sketch when USB 'Message' is sent to the Teensy, which is echoed back. That arriving output stays offscreen and doesn't autoscroll into view.

This behavior is changed from IDE 2.0.2:

void setup() {
  pinMode( LED_BUILTIN, OUTPUT );
  digitalWrite( LED_BUILTIN, HIGH );
  Serial.begin(115200);
  while (!Serial);
  digitalWrite( LED_BUILTIN, LOW );
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.print( "run secs A=" );
  Serial.println( millis()/1000.0 );
  delay(1000);               // wait for a second
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  Serial.print( "run secs B=" );
  Serial.println( millis()/1000.0 );
  showSome( 3 );
}

void loop() {
  // put your main code here, to run repeatedly:
  if ( Serial.available() )
    showSome( 3 );
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(500);               // wait for a second
}

void showSome( int cnt ) {
  static uint nn=1;
  int ch;
  while ( (ch=Serial.read()) > -1 ) {
    Serial.print( (char)ch );
  }
  int ii;
  for ( ii=0; ii<cnt; ii++ ) {
    Serial.print( "See Me: " );
    Serial.println( ii+nn );
  }
  nn+=ii;
}

@per1234
Copy link
Contributor

per1234 commented Dec 5, 2022

That arriving output stays offscreen and doesn't autoscroll into view.

@Defragster does it eventually autoscroll into view if additional lines of output arrive?

@Defragster
Copy link
Author

Generally no, except in some amusing pattern:

Upload sketch (above) T_4.1 with IDE SerMon active - minimal out presented shows:
`
C:\T_Drive\tCode\FORUM\serialIDE2test\serialIDE2test.ino Dec 5 2022 12:12:56
run secs A=1.06

C:\T_Drive\tCode\FORUM\serialIDE2test\serialIDE2test.ino Dec 5 2022 12:12:56
run secs B=2.06
See Me: 1
See Me: 2
See Me: 3`

Upload again output in view advances only to:
C:\T_Drive\tCode\FORUM\serialIDE2test\serialIDE2test.ino Dec 5 2022 12:14:04 run secs A=1.07

Go to Message and send 'Hello' - output advances to prior:
C:\T_Drive\tCode\FORUM\serialIDE2test\serialIDE2test.ino Dec 5 2022 12:14:04 run secs B=2.07 See Me: 1 See Me: 2 See Me: 3

Go to Message and send 'Goodbye' - output advances to prior:
Hello See Me: 4 See Me: 5 See Me: 6

Mouse wheel Scroll down to see:
Goodbye See Me: 7 See Me: 8 See Me: 9

Go to Message and send 'Arduino' - output does not advance.

Same here IDE 2.0.3 Win 11 with IDE and PJRC Teensy Ports.

@PaulStoffregen
Copy link

Confirm, also seeing poor autoscroll behavior with IDE 2.0.3. Could record another video, if that would help?

@per1234
Copy link
Contributor

per1234 commented Dec 9, 2022

Hi @PaulStoffregen. The defect that is the subject of this issue: "Serial Monitor does not Autoscroll on new content received when view is not in focus" is already quite clear to me and easy to reproduce. So no additional clarification is needed. It is only necessary to wait for someone to prepare the code changes to fix the defect.

As for what appears to possibly be a separate defect reported at #1724 (comment), I have not been able to understand it. If that is indeed a separate defect, please do submit a separate issue for it with a clear description of the problem and detailed instructions we can follow to reproduce it. We should be careful to keep each issue focused on a single subject because otherwise they become very difficult and time consuming for the team to manage.

@Defragster
Copy link
Author

That last @per1234 comment "keep each issue focused on a single subject " refers to this #1724? The title was changed 6 days ago - which changed what the issue covered?

This is okay as it seems a change from 2.0.2 to 2.0.3 has eliminated the problem related to this issue where the initially reported 'drawing on an out of focus Sermon display window' resulted in seeing a blank window when it was put in focus. Now the window text is updated and draws - but per new title and recent comments it just fails to automatically scroll to the latest arriving information.

Seems for my last post here I did see a blank screen once - but all will be well perhaps in the end if auto scrolling starts working correctly as it seems to be a variant of the same evolving behavior of this issue. Indeed, if not then a new issue makes sense with then current details to repro.

@per1234 per1234 added the topic: serial monitor Related to the Serial Monitor label Jan 1, 2023
kittaakos pushed a commit that referenced this issue Mar 3, 2023
Closes #1724

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
kittaakos pushed a commit that referenced this issue Mar 7, 2023
Closes #1724

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
@kittaakos kittaakos added the conclusion: resolved Issue was resolved label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: serial monitor Related to the Serial Monitor type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants