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

stopApp not working on Window when started with runApp(..., launch.browser = TRUE) #894

Closed
vnijs opened this issue Jul 15, 2015 · 9 comments

Comments

@vnijs
Copy link
Contributor

vnijs commented Jul 15, 2015

Having trouble with stopApp on Windows when adding launch.browser = TRUE. Works fine on Mac but on Windows nothing happens. Sessioninfo given below.

Dropbox link for ui.R and server.R:
https://www.dropbox.com/sh/p0mdx8fr0wljy4h/AAA1p82DeC4JAb0pjP-XBQXCa?dl=0

ui.R:

shinyUI(
  navbarPage("Stop", windowTitle = "Stop app", id = "nav",
       collapsible = TRUE,
       tabPanel("Something"),
       navbarMenu(title = "Stop",
                   tabPanel(tags$a(id = "stop_radiant", href = "#", class = "action-button",
                            list(icon("stop"), "Stop"), onclick = "window.close();"))
    )
  )
)

Server.R

shinyServer(function(input, output, session) {
    observeEvent(input$stop_radiant, {
      stopApp()
  })
})

R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_0.12.1

loaded via a namespace (and not attached):
[1] R6_2.1.0 htmltools_0.2.6 tools_3.2.0 rstudioapi_0.3.1 Rcpp_0.11.6 rstudio_0.98.1103
[7] jsonlite_0.9.16 digest_0.6.8 xtable_1.7-4 httpuv_1.3.2 mime_0.3

@kmezhoud
Copy link

Hi,
No error message when I clic on "Stop" for mac

shiny::runApp('/Volumes/DATA/radiant/test')
Listening on http://127.0.0.1:6775
NULL

sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.4 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_0.12.1

loaded via a namespace (and not attached):
[1] htmlwidgets_0.5 magrittr_1.5 R6_2.1.0 htmltools_0.2.6
[5] tools_3.2.1 rstudioapi_0.3.1 Rcpp_0.11.6 DT_0.1
[9] R.methodsS3_1.7.0 jsonlite_0.9.16 rpivotTable_0.1.4 digest_0.6.8
[13] xtable_1.7-4 httpuv_1.3.2 mime_0.3 R.oo_1.19.0

@wch
Copy link
Collaborator

wch commented Jul 15, 2015

@vnijs Does the same thing happen when you launch from RStudio and the plain old R GUI? We had another issue (#869) that was related to launching an app from RStudio.

@kmezhoud Please also take a look at #869 and see if it's relevant to you.

@jcheng5
Copy link
Member

jcheng5 commented Jul 15, 2015

For @vnijs maybe the window is closing before the stop message is sent?

@jcheng5
Copy link
Member

jcheng5 commented Jul 15, 2015

@vnijs If the objective is to stop the loop when the user goes away, you could also use something like session$onSessionEnded(stopApp).

@vnijs
Copy link
Contributor Author

vnijs commented Jul 15, 2015

@wch Same things happens on Windows when launching from Rgui or from a terminal. No issues on Mac (viewer or browser, Chrome or Safari) or when using the Rstudio viewer on windows. The issue occurs when launching to a browser on Windows (Chrome). Interestingly, the link does seem to work on windows with Firefox although is doesn't close the browser.

@jcheng5 On 'window closing before stop message' ... could be. Not sure. Why would closing the window interupt the observeEvant? Also, should that timing be different on Mac and Windows (both Chrome)? Everything works fine on mac. For firefox on windows the app is stopped but the browser is not closed. Question: To test the timing hypothesis can you call "window.close();" from an observeEvent? If so, how-to?

@jcheng5 I already use onSessionEnded to save state. This is necessary to ensure state is not lost on refresh or if a user accidentally closes a tab.

@vnijs
Copy link
Contributor Author

vnijs commented Jul 15, 2015

@wch I don't think this issue is related to #869

However, the following issue might be vnijs/radiant#22 (comment) It seems the Rstudio viewer hides inputs that the browser does show.

@kmezhoud
Copy link

@wch No crash/error for this issue #869.
Thanks

@vnijs
Copy link
Contributor Author

vnijs commented Jul 16, 2015

@jcheng5 Looks like you were right. I added a small delay to window.close and now it works as intended on Windows (Chrome) as well (see below). It still seems a bit odd that the timing is different on Mac and Windows (both Chrome)?

tabPanel(actionLink("stop_radiant", "Stop", icon = icon("stop"), onclick = "setTimeout(function(){window.close();}, 100); "))

@vnijs
Copy link
Contributor Author

vnijs commented Jul 16, 2015

@wch Any idea why the Rstudio viewer might hide elements an external browser does show? Let me know if this should be a separate issue and you want to close this one.

@vnijs vnijs closed this as completed Jul 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants