Pink Screen with VideoMaterial in ARKit

Hi everyone,

I'm developing an ARKit app using RealityKit and encountering an issue where a video displayed on a 3D plane shows up as a pink screen instead of the actual video content.

Here's a simplified version of my setup:

func createVideoScreen(video: AVPlayerItem, canvasWidth: Float, canvasHeight: Float, aspectRatio: Float, fitsWidth: Bool = true) -> ModelEntity {
    let width = (fitsWidth) ? canvasWidth : canvasHeight * aspectRatio
    let height = (fitsWidth) ? canvasWidth * (1/aspectRatio) : canvasHeight
    let screenPlane = MeshResource.generatePlane(width: width, depth: height)

    let videoMaterial: Material = createVideoMaterial(videoItem: video)
    let videoScreenModel = ModelEntity(mesh: screenPlane, materials: [videoMaterial])
    return videoScreenModel
}

func createVideoMaterial(videoItem: AVPlayerItem) -> VideoMaterial {
    let player = AVPlayer(playerItem: videoItem)
    let videoMaterial = VideoMaterial(avPlayer: player)
    player.play()
    return videoMaterial
}

Despite following the standard process, the video plane renders pink. Has anyone encountered this before, or does anyone know what might be causing it?

Thanks in advance!

Hello @mr_app,

Is it a pink-striped material? That is what RealityKit renders if there is a model with no material set. Is it possible that you are removing the videoMaterial you have set in the code you have shown?

Best regards,

Greg

Same problem, video material pink on ios 18

are there any solutions?

I have the same issue: the video material is pink on iOS 18. On iOS 17, it is working fine.

When I track my AR asset, it starts playing the video. I can hear the audio, but I have this pink video. On iOS 17, it is working fine, but on iOS 18, I have this bug. Any suggestion on how to fix it?

That is my code, I still have the pink material for iOS 18. While on iOS 17 is working fine. Any advice?

// Create Video Screen
private func createVideoScreen(width: Float, height: Float, url: URL, uuid: UUID) -> ModelEntity {
    let screenMesh = MeshResource.generatePlane(width: width, height: height)
    let videoItem = createVideoItem(with: url)
    let videoMaterial = createVideoMaterial(with: videoItem, uuid: uuid)
    let videoScreenModel = ModelEntity(mesh: screenMesh, materials: [videoMaterial])
    return videoScreenModel
}

// Create Video Item
private func createVideoItem(with url: URL) -> AVPlayerItem {
    let asset = AVURLAsset(url: url)
    let videoItem = AVPlayerItem(asset: asset)
    return videoItem
}

// Create Video Material
private func createVideoMaterial(with videoItem: AVPlayerItem, uuid: UUID) -> VideoMaterial {
    let player = AVPlayer()
    player.actionAtItemEnd = .none
    let videoMaterial = VideoMaterial(avPlayer: player)
    player.replaceCurrentItem(with: videoItem)
    player.play()
    
    NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: player.currentItem, queue: .main) { _ in
        player.seek(to: .zero)
        player.play()
    }
    videoPlayers[uuid] = player
    return videoMaterial
}

// Place Video Screen
private func placeVideoScreen(videoScreen: ModelEntity, imageAnchor: ARImageAnchor, uuid: UUID) {
    guard let arView = arView else { return }
    
    let imageAnchorEntity = AnchorEntity(anchor: imageAnchor)
    let rotationAngle = simd_quatf(angle: GLKMathDegreesToRadians(-90), axis: SIMD3(x: 1, y: 0, z: 0))
    videoScreen.setOrientation(rotationAngle, relativeTo: imageAnchorEntity)
    imageAnchorEntity.addChild(videoScreen)
    
    arView.scene.addAnchor(imageAnchorEntity)
    activeAnchors[uuid] = imageAnchorEntity
}

Same issue, iOS 18.1.1; solid pink, not striped

Pink Screen with VideoMaterial in ARKit
 
 
Q