shinyapps.io + rmarkdown save leaflet map error

Hi, I built a shinyapp to generate a report containing map images according to input coordinates. It works fine locally but not the case with shinyapps.io. I'm thinking I must make some mistakes on the folder path since I'm using leaflet and mapview, which saves the static map as a png file then print it.

The following is a simple version of my application:

app.R

library(leaflet)
library(mapview)
library(leaflet.providers)

shinyApp(
  ui = fluidPage(
    textInput("Lat", "lat", 45),
    textInput("Lon", "lon", -93),
    downloadButton("report", "Generate report")
  ),
  server = function(input, output) {
    output$report <- downloadHandler(
      filename = "report.pdf",
      content = function(file) {
        # Copy the report file to a temporary directory before processing it, in
        # case we don't have write permissions to the current working dir (which
        # can happen when deployed).
        tempReport <- file.path(tempdir(), "report.Rmd")
        file.copy("report.Rmd", tempReport, overwrite = TRUE)
   
        # Set up parameters to pass to Rmd document
        params <- list(lat = input$Lat, lon = input$Lon)
        
        # Knit the document, passing in the `params` list, and eval it in a
        # child of the global environment (this isolates the code in the document
        # from the code in this app).
        rmarkdown::render(tempReport, output_file = file,
                          params = params,
                          envir = new.env(parent = globalenv())
        )
      }
    )
  }
)

report.rmd

---
title: "Map Report"
always_allow_html: yes
linestretch: 1.25
fontsize: 12pt
output:
  pdf_document: 
params:
  lat: NA
  lon: NA
---

```{r, echo=FALSE}
# The `params` object is available in the document.
sprintf("Input lat is %s", params$lat)
sprintf("Input lon is %s", params$lon)

Map

m <- leaflet() %>% 
  addProviderTiles('Esri.WorldImagery') %>%
  setView(params$lon, params$lat, zoom = 20) %>%
  addPopups(lng = as.numeric(params$lon), lat = as.numeric(params$lat), popup = sprintf("%.2f, %.2f", as.numeric(params$lat), as.numeric(params$lon)))

mapshot(m, file = "map.png", remove_url = TRUE)

r sprintf("![Satellite View](%s)", "map.png")


shinyapps.io gave errors as follows:

2020-07-14T19:56:51.137171+00:00 shinyapps[2570823]: ! Package pdftex.def Error: File `map.png' not found.
2020-07-14T19:56:51.137173+00:00 shinyapps[2570823]: 
2020-07-14T19:56:51.139603+00:00 shinyapps[2570823]: Warning: Error in : LaTeX failed to compile /tmp/RtmpcILEaW/file181ec0cbc2.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See file181ec0cbc2.log for more info.
2020-07-14T19:56:51.144014+00:00 shinyapps[2570823]:   [No stack trace available]

Thanks for your help!