P2D Misbehaviour

I needed to adapt a fairly large application to use P2D instead of JAVA2D as the main renderer, because a new feature uses some 3D graphics (createGraphics(wdth,hght, P3D)) and this is evidently not possible with the main renderer being the default JAVA2D. However, switching from JAVA2D to P2D made the application behave very strangly indeed!
I can illustrate the problem with the following small code example:

size( 800, 500, P2D );
PFont f = createFont( "Arial", 95 );
PGraphics og = createGraphics( 600, 200, P2D ); // outer graphics
og.beginDraw();
og.background( 255, 0, 0 );
PGraphics ig = createGraphics( 500, 150, P2D );  // inner graphics
ig.beginDraw();
ig.background( 0, 255, 0 );
ig.textFont( f );
ig.fill(0, 0, 255 );
ig.rect( 50, 5, 400, 110 );
ig.textAlign( LEFT, TOP );
ig.fill(0);
ig.text("hello", 50, 5 );
ig.endDraw();
og.image( ig, 10, 20 );  // only works if inner graphics is JAVA2D!!!
og.endDraw();
image( og, 10, 10 );
image( ig, 100, 300 );  // here it works

If the inner graphic (ig) is JAVA2D, or all of them are JAVA2D it works just fine.
However with ig using P2D, it all gows wrong!?

This is what it SHOULD look like and what it DOES look like:

Anyone any ideas?

Addendum: Further investigation shows that the problem occurs when nesting beginDraw() / endDraw() calls for PGraphics (where one is the component of the other). P2D (and P3D) create a (spurious) positive y-translation and scale (or z-translation) for each inner draw operation! JAVA2D work fine.

Hello,

Please format your code:
https://discourse.processing.org/faq#format-your-code

It should look like this formatted:

void setup() 
	{
  size(600, 600);
  textSize(96);
  textAlign(CENTER);
  }

void draw() 
	{
  background(0);
  translate(width/2, height/2);
  float angle = frameCount*TAU/360;
  rotate(angle);
  textSize(50 + 48*sin(angle));
  
  text("Please format your code!", 0, 0);
	}

:)