When using WKWebview to load the following url on iOS17.5, The Camara preview page is likely to not display the image, but there is no error report. The video cannot be loaded. There is no problem with iOS17 and iOS18.
I can't find the cause of the error, How to avoid this problem? I hope you can provide some suggestions. I want a way to avoid the error,Thanks
STEPS TO REPRODUCE
Run iOSTest.xcodeproj on iOS17.5
Tap WKWebview(Camara)
Waiting webview load url
tap 手持设备训练 立即开始
download demo
https://github.com/xuty/Report22/raw/refs/heads/main/iOSTest_1_url.zip
Post
Replies
Boosts
Views
Activity
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>