From c05ad4d0609c22a0c1d9fc1dde633325d048b589 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 7 Apr 2026 16:46:09 +0200 Subject: [PATCH] Remove CALayer from super layer on surface destruction --- src/backends/cg.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backends/cg.rs b/src/backends/cg.rs index 789dd442..29879b70 100644 --- a/src/backends/cg.rs +++ b/src/backends/cg.rs @@ -131,6 +131,9 @@ impl Drop for CGImpl { self.root_layer .removeObserver_forKeyPath(&self.observer, ns_string!("bounds")); } + + // Remove the layer we created from the root layer. + self.layer.removeFromSuperlayer(); } } @@ -179,6 +182,8 @@ impl SurfaceInterface for CGImpl< // Add a sublayer, to avoid interfering with the root layer, since setting the contents of // e.g. a view-controlled layer is brittle. + // + // This layer is removed from the root layer when the surface is `Drop`ped. let layer = CALayer::new(); root_layer.addSublayer(&layer);