You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mediaplayer/src/jvmMain/kotlin/io/github/kdroidfilter/composemediaplayer/windows/WindowsVideoPlayerState.kt
+8-20Lines changed: 8 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -346,19 +346,10 @@ class WindowsVideoPlayerState : VideoPlayerState {
346
346
347
347
// Free bitmaps and frame buffers
348
348
bitmapLock.write {
349
-
val currentFrame =_currentFrame
350
-
if (currentFrame !=null&&
351
-
currentFrame !== skiaBitmapA &&
352
-
currentFrame !== skiaBitmapB
353
-
) {
354
-
currentFrame.close()
355
-
}
356
349
_currentFrame=null
357
350
currentFrameState.value =null
358
351
359
-
// Clean up double-buffering bitmaps
360
-
skiaBitmapA?.close()
361
-
skiaBitmapB?.close()
352
+
// Don't close bitmaps — see comment in releaseAllResources().
362
353
skiaBitmapA =null
363
354
skiaBitmapB =null
364
355
skiaBitmapWidth =0
@@ -391,19 +382,16 @@ class WindowsVideoPlayerState : VideoPlayerState {
391
382
392
383
// Free bitmaps and frame buffers
393
384
bitmapLock.write {
394
-
val currentFrame =_currentFrame
395
-
if (currentFrame !=null&&
396
-
currentFrame !== skiaBitmapA &&
397
-
currentFrame !== skiaBitmapB
398
-
) {
399
-
currentFrame.close()
400
-
}
401
385
_currentFrame=null
402
386
currentFrameState.value =null
403
387
404
-
// Clean up double-buffering bitmaps
405
-
skiaBitmapA?.close()
406
-
skiaBitmapB?.close()
388
+
// Do NOT close the double-buffer bitmaps here: the ImageBitmap
389
+
// exposed via currentFrameState shares the same native pixel memory
390
+
// (asComposeImageBitmap is zero-copy). Compose may still be rendering
391
+
// the last frame on the AWT-EventQueue thread. Closing now would free
392
+
// the native memory while Skia reads it, causing an access violation.
393
+
// Nullifying the references lets the Skia Managed cleaner release them
394
+
// once Compose (and any other holder) drops its reference.
0 commit comments