When using WKWebview to load the following html on iOS17.5 Simulator, navigator.mediaDevices.getUserMedia reports an error (A MediaStreamTrack ended due to a capture failure), but the then branch can be executed. The video cannot be loaded. There is no problem with iOS17 Simulator and iOS18 Simulator. Thank you very much for answering the question.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, viewport-fit=cover">
<title>WebKit Camera Preview</title>
</head>
<body>
<div id="content" style="margin-top:env(safe-area-inset-top);background-color:blue">
<button style="width:200;height:40px;" onclick="doClick()">open camara</button>
</div>
<video playsinline id="myVideo" ></video>
<script>
var ggstream = null
function doClick(){
const content = document.getElementById("content")
content.style.backgroundColor = "red"
navigator.mediaDevices.getUserMedia({
video : true})
.then(stream => {
const video = document.getElementById('myVideo');
video.srcObject = stream;
video.play()
})
.catch(err => {
console.error('Error accessing media devices.', err);
});
}
</script>
</body>
</html>