JohnCoene / firebase

Google FIrebase for shiny
https://firebase.john-coene.com
GNU Affero General Public License v3.0
170 stars 26 forks source link

Example App does not render anything in Firefox, sometimes #46

Open dcaud opened 1 year ago

dcaud commented 1 year ago

The below works reliably in Chrome and Safari, but only intermittently Firefox. When it doesn't work, nothing is rendered in the Firefox browser.

library(shiny)
library(firebase)

ui <- fluidPage(
  useFirebase(), # import dependencies,
  firebaseUIContainer()
)

server <- function(input, output){
  f <- FirebaseUI$
    new()$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )$
    launch() # launch
}

shinyApp(ui, server)

The rendered HTML in Firefox (using view page source in Firefox) looks identical when it works and doesn't work. There are no errors in the Firefox console. Opening a new tab and pasting the locally generated URL (from Shiny, using RStudio) sometimes results in the expected Firebase login buttons, but sometimes does not. This appears to be a problem with how Firefox is rendering the JS or something else with Firefox (that is, the same Shiny instance sometimes works in Firefox, but sometimes doesn't).

JohnCoene commented 1 year ago

Can you try

server <- function(input, output){
  f <- FirebaseUI$
    new()$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )

  observe({
    launch() # launch
  })
}
dcaud commented 1 year ago

A couple notes:

1) I could reliably reproduce the problem with my example and restarting the R session before launching the app. It seems that something is likely cached on first load, which makes subsequent loads work as expected.

2) Your code, I presume, needs to have a "f$" in front of launch() inside the observe(). With that revision, as I've pasted below, it now seems to work as expected in Firefox -- reliably.

library(shiny)
library(firebase)

ui <- fluidPage(
  useFirebase(), # import dependencies,
  firebaseUIContainer()
)

server <- function(input, output){
  f <- FirebaseUI$
    new()$ # instantiate
    set_providers( # define providers
      email = TRUE, 
      google = TRUE
    )

  observe({
    f$launch() # launch
  })
}

shinyApp(ui, server)
JohnCoene commented 1 year ago

Indeed. The real issue here is that I am still unsure what is happening.

This has been pointed out before, I have to change the documentation but have not found the time.