@@ -383,9 +383,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
383383 const { enableMultiPassRenderer, passes } = this . getLayerConfig ( ) ;
384384 if ( enableMultiPassRenderer && passes ?. length && passes . length > 0 ) {
385385 // Tip: 兼容 multiPassRender 在 amap1 时存在的图层不同步问题 zoom
386- this . mapService . on ( 'mapAfterFrameChange' , ( ) => {
387- this . renderLayers ( ) ;
388- } ) ;
386+ this . mapService . on ( 'mapAfterFrameChange' , this . onMapAfterFrameChange ) ;
389387 }
390388
391389 this . postProcessingPassFactory = this . container . postProcessingPassFactory ;
@@ -871,6 +869,8 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
871869 }
872870
873871 this . hooks . beforeDestroy . call ( ) ;
872+ // 解除 mapAfterFrameChange 监听(修复历史匿名回调泄漏,与 onSourceUpdate 对称)
873+ this . mapService . off ( 'mapAfterFrameChange' , this . onMapAfterFrameChange ) ;
874874 // 清除sources事件
875875 this . layerSource . off ( 'update' , this . onSourceUpdate ) ;
876876
@@ -1263,6 +1263,18 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
12631263 }
12641264 } ;
12651265
1266+ /**
1267+ * `mapAfterFrameChange` 事件监听器(稳定实例引用,供 on/off 配对解绑)。
1268+ *
1269+ * 修复历史泄漏:原先在 init 内以 inline arrow 注册,destroy 时无法 off
1270+ * (引用不匹配),监听器随图层销毁后仍挂在 mapService 上泄漏。提取为具名
1271+ * 实例箭头方法后 on/off 统一引用,解绑真实生效。仅在 enableMultiPassRenderer
1272+ * + passes 下注册;destroy 内无条件 off(未注册时 off 为空操作,无害)。
1273+ */
1274+ protected readonly onMapAfterFrameChange = ( ) : void => {
1275+ this . renderLayers ( ) ;
1276+ } ;
1277+
12661278 protected async initLayerModels ( ) {
12671279 this . models . forEach ( ( model ) => model . destroy ( ) ) ;
12681280 this . models = [ ] ;
0 commit comments