Skip to content

Code browser automatically opening when debugging R Shiny #12505

Closed

Description

@vfridkin

Using 2022.07.1 Build 554.pro3

The code browser tab (it has two dots, see below for example) opens every time a line of code is run while debugging in R Shiny using browser() statements. This decreases the joy of debugging significantly due to having to constantly switch off the added tab and find where the debugging got to in the original tab for every code line being run.

Expected behaviour: During debugging, RStudio keeps focus where the user ran the code.
Current behaviour: Opens new tab and/or moves to another tab automatically each time a block of code is executed during debugging.

This issue has been raised here on 2020 and comments made suggested it had been already fixed
#6740

Also raised here
#9943

And I've asked here with no satisfaction
https://stackoverflow.com/questions/69652407/debugging-r-shiny-with-browser-statements-less-painfully

Image shows the unwanted tab that opens automatically. May this two dotted monster be banished eternally for the unhappiness it has wrought!
image

Activity

  1. ronblum commented on Dec 29, 2022

    @ronblum
    Contributor

    @vfridkin Thank you for raising this! Rather than reopening one of the existing issues, lets use this issue. Did this behave as you'd like in any previous versions? There's some indication that the behavior changed in a previous release, but that's not consistent. I'm trying to determine if this is a regression or a continuing enhancement.

    Triage: Note earlier comments and upvotes.

  2. vfridkin commented on Dec 30, 2022

    @vfridkin
    Author

    @ronblum Yes, this behaved as I (and my 100+ team 😄) liked in version 1.1.463. We moved our stuff to new servers and engineering updated our RStudio recently.
    image

    Please note, it seems that editing the code while debugging triggers the tabs opening - which is what I do 100% of the time when debugging.

    My understanding is that during debugging, RStudio recognizes that the code being edited (edits) is different from the saved code (saved) and keeps opening or moving to the saved tab instead of staying in the edits tab.

  3. ronblum commented on Dec 30, 2022

    @ronblum
    Contributor

    @vfridkin Thanks! I tried to run the code in RStudio Desktop 1.1.463 with R 3.3.3. I'm not seeing the same behavior, but I might be following the same steps. However, I did notice that starting with version 1.4.1106, there's a bug in which the cursor loses focus—previously, it remained in the Console Pane.

    @kevinushey What is the expected behavior? I might not be replicating the exact steps as @vfridkin which might explain the difference the @vfridkin and I are seeing even in 1.1.463.

    FWIW, I used the following code, snatched from the previous issues:

    a <- function() b()
    b <- function() c()
    c <- function() {
      x <- 10
      browser()
      x
    }
    a()
    
    myfun <- function(x) print(x)
    debugonce(myfun)
    myfun("test")
    
  4. vfridkin commented on Jan 2, 2023

    @vfridkin
    Author

    @ronblum I've used your example in both 2022.07.1 (new) and 1.1.463 (old). I was able to generate the issue in new and for the same test, it did not occur in old.

    Here are the steps:

    1. saved your code in a test.R file
    2. with the code open, sourced the file
    3. now in browse/debug mode, added a line after the browser() like this
      image
    4. execute the added line while still in browse mode

    In new it opened a new tab to the original code without the added line.
    image

    In old it didn't open a new tab - this is the desired behaviour as it enables editing during debugging and seeing the effect of these edits with the variables defined in the debug state.
    image

  5. cm421 commented on Jan 11, 2023

    @cm421
    Contributor

    Linking customer ticket #84078 here because they seem to be experiencing a similar issue on Workbench 2022.07.1+554.pro3

  6. kevinushey commented on Jan 12, 2023

    @kevinushey
    Collaborator

    FWIW, I'm not able to reproduce in the latest RStudio release (2022.12.0).

  7. mikebessuille commented on Jan 17, 2023

    @mikebessuille
    Contributor

    @vfridkin can you please confirm if this problem exists in the latest release, 2022.12.0? We have been unable to reproduce this.

  8. lachlansimpson commented on Jan 18, 2023

    @lachlansimpson

    Linking customer ticket #84410, I have asked for a reproduction in 2022.12.

  9. itsshubhamsaxena commented on Mar 21, 2023

    @itsshubhamsaxena

    Hi, I am also facing exactly same problem with 2022.12.0+353.pro20 Workbench (Elsbeth Geranium) for RHEL 8

  10. rich-rstudio commented on Mar 21, 2023

    @rich-rstudio
    Contributor

    I was able to reproduce on RHEL 8 workbench 2023.03.1 Build 409.pro2 and 2022.12.1+366.pro6

  11. lachlansimpson commented on Apr 11, 2023

    @lachlansimpson

    Ticket #88232 has this issue as well, this is a reproduction in 2022.12 from ticket #84078 mentioned in this comment above.

  12. 13 remaining items

  13. removed their assignment
    on Jun 16, 2023
  14. lachlansimpson commented on Sep 3, 2023

    @lachlansimpson

    Ticket #94715 has asked about this issue.

  15. kevinushey commented on Sep 6, 2023

    @kevinushey
    Collaborator

    Maybe I'm misunderstanding, but it looks like this issue has been resolved in the latest daily builds? It's hard to be certain because we don't have a concrete reproducible example for Shiny in this issue. Here's the Shiny application I tried running:

    
    library(shiny)
    
    ui <- fluidPage(
      titlePanel("Debugging with Shiny"),
      textOutput("text")
    )
    
    server <- function(input, output) {
      output$text <- renderText({
        print(1 + 1)
        browser()
        print(2 + 2)
        browser()
        print(3 + 3)
        "Hello, world!"
      })
    }
    
    # Run the application
    shinyApp(ui = ui, server = server)
    

    When I start the Shiny application, the browser() breakpoint is hit. I can then switch to different editors, or run code in the console, and focus is never aggressively shifted back to the original source file. This is true even if I run the script by:

    • Highlighting the code and sending to console with Cmd + Enter (but we don't have srcrefs in this case),
    • Running the script via the Run App button,
    • Running the script with Cmd + Shift + S (to Source the script)

    Is this an accurate description of the issue? If so, and if someone is still encountering this issue with the latest daily builds, could you please let us know? It could also help if you could share a screen cast of what behavior exactly you're seeing.

  16. jthomasmock commented on Sep 11, 2023

    @jthomasmock
    Contributor

    On MacOs: "2023.09.0-daily+410" and re: ticket #94715 - I think this is a separate issue more related to individual function debugging vs Shiny.

    For #94715 - I am able to stay in the source file when editing that file, running code and assigning new variables, and the debug browser read only pane only opens up when I call a separate user-defined function.

  17. vfridkin commented on Sep 26, 2023

    @vfridkin
    Author

    It is still an issue with the version we are using:
    RStudio 2023.06.1+524.pro1 "Mountain Hydrangea" Release (7025e95, 2023-07-06) for RHEL 8
    Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36

    Please note, we are using Shiny modules throughout.
    If it has been fixed in a subsequent version, please let me know.

  18. ronblum commented on Sep 27, 2023

    @ronblum
    Contributor

    @vfridkin We just released a new version of RStudio yesterday, version 2023.09.0+463. The problem should be (hopefully!) resolved in it. Can you try it out?

  19. jthomasmock commented on Nov 9, 2023

    @jthomasmock
    Contributor

    Using Kevin's example and "Run App", I'm not able to reproduce the opening of a new View only browser view.

    debug-shiny.mp4
  20. kevinushey commented on Nov 9, 2023

    @kevinushey
    Collaborator

    @vfridkin, the issue appears to be resolved on our end. If you can, please try testing one of the latest daily builds at https://dailies.rstudio.com. We're going to close this issue as resolved, but please feel free to re-open with more details if you're still having trouble.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions