posit-dev / positron

Positron, a next-generation data science IDE
Other
2.5k stars 77 forks source link

Positron window terminates unexpectedly with Mapbox in Plots pane #3230

Open juliasilge opened 4 months ago

juliasilge commented 4 months ago

Discussed in https://github.com/posit-dev/positron-beta/discussions/198

Originally posted by **JosiahParry** May 21, 2024 Repros without fail for me: image Shapefile here to repro [taxi_zones.zip](https://github.com/posit-dev/positron-beta/files/15389655/taxi_zones.zip) ```r # needs rdeck from github # https://qfes.github.io/rdeck/articles/rdeck.html # and sf, wk, and dplyr locs <- sf::read_sf("data/data-raw/nyc-taxi-2023-taxi/taxi-zones/taxi_zones.shp") |> sf::st_transform(4326) |> dplyr::mutate(geometry = wk::wk_polygon(geometry)) library(rdeck) rdeck( initial_view_state = view_state( initial_exetent = wk::wk_bbox(locs$geometry), zoom = 6.6, bearing = -27.5, pitch = 40.5 ) ) |> add_polygon_layer( data = locs, id = "heatmap", coverage = 1, pickable = TRUE, auto_highlight = TRUE, elevation_range = c(0, 3000), elevation_scale = 50, extruded = TRUE, get_polygon = geometry, color_range = c( rgb(1, 152, 189, maxColorValue = 255), rgb(73, 227, 206, maxColorValue = 255), rgb(216, 254, 181, maxColorValue = 255), rgb(254, 237, 177, maxColorValue = 255), rgb(254, 173, 84, maxColorValue = 255), rgb(209, 55, 78, maxColorValue = 255) ) ) ```
juliasilge commented 4 months ago

Running this code requires downloading the data Josiah shared as well as a Mapbox account, but the free tier seems to work.

Running just the rdeck() bit seems fine (no crash and displays the htmlwidget in the Plots pane) but when you add on add_polygon_layer() it crashes. Here is a slightly more minimal example:

locs <- sf::read_sf("data/data-raw/nyc-taxi-2023-taxi/taxi-zones/taxi_zones.shp") |> 
  sf::st_transform(4326) |> 
  dplyr::mutate(geometry = wk::wk_polygon(geometry))

library(rdeck)
rdeck(
  initial_view_state = view_state(
    initial_exetent  = wk::wk_bbox(locs$geometry),
    zoom = 6.6,
    bearing = -27.5,
    pitch = 40.5
  )
) |>
  add_polygon_layer(
    data = locs,
    get_polygon = geometry
  )