NullPointerException when calling save() after surface.setSize() in P2D

Glad to hear!

I’m not sure I understand – can you explain what you mean by that? Are you trying to set it separately from the main canvas? This works fine on my Retina MacBook:

PGraphics pg;

void setup() {
  pixelDensity(2);                // set density
  println(g.pixelDensity);        // check canvas density -- 2
  pg = createGraphics(100, 100);  // create graphics
  println(pg.pixelDensity);       // check graphics density -- 2
  pg.beginDraw();
  pg.ellipse(75, 50, 20, 20);     // draw graphics circle
  pg.endDraw();
}

void draw() {
  background(192);
  ellipse(25, 50, 20, 20);        // draw circle
  image(pg, 0, 0);                // render graphics circle -- same
}

PixelDensityOnPGraphics