iOS Question Signal 11 Error on WebView

db0070

Active Member
Licensed User
Longtime User
I get this intermittent error when I play a video in webview. It appears intermittently at various points of user interaction with the video. I have tried webview1.release when the user presses the Back Nav control button.

Error occurred on line: 457 (Main)
Signal - 11
Stack Trace: (
"0 Talimul Quran AMA UK SignalHandler + 120",
"1 libsystem_platform.dylib 0x0000000208a8d9e0 <redacted> + 40",
"2 libsystem_blocks.dylib 0x0000000208916a44 _Block_release + 152",
"3 libdispatch.dylib <redacted> + 16",
"4 libdispatch.dylib <redacted> + 1068",
"5 CoreFoundation <redacted> + 12",
"6 CoreFoundation <redacted> + 1964",
"7 CoreFoundation CFRunLoopRunSpecific + 436",
"8 GraphicsServices GSEventRunModal + 100",
"9 UIKitCore UIApplicationMain + 212"
)

If I set WebView1.UserInteractionEnabled = False, it helps, but this is not ideal for my app.

B4X:
Sub PlayVideo(videoId As String)
    NavControl.ShowPage(Page2)
    WebView1.UserInteractionEnabled = True
    Dim  no As NativeObject = WebView1
    no.RunMethod("setMediaPlaybackRequiresUserAction:", Array(true))
    WebView1.LoadHtml($"<!DOCTYPE html><html>
   <head>
   <style>body{margin:0px 0px 0px 0px;}</style></head>
    <body> <div id="player"></div>
    <script> var tag = document.createElement('script');
    tag.src = "https://www.youtube.com/player_api";
    var firstScriptTag = document.getElementsByTagName('script')[0];
    firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
    var player; function onYouTubePlayerAPIReady()
    { player = new YT.Player('player', { width:'${WebView1.Width}', height:'${WebView1.Height}', videoId:'${videoId}', events: { 'onReady': onPlayerReady, } }); }
    function onPlayerReady(event) { event.target.playVideo(); }
    </script> </body> </html>"$)
End Sub
 

db0070

Active Member
Licensed User
Longtime User
WKWebView works. It does not auto play the youtube video, but for the moment I am happy with it like this, and my app is now on the app store. Thanks.
Had to remove this line for WKWebView to work
B4X:
no.RunMethod("setMediaPlaybackRequiresUserAction:", Array(true))
 
Upvote 0
Top