B4J Question EXCEPTION_ACCESS_VIOLATION : Webview with jScriptEngine

jmon

Well-Known Member
Licensed User
Longtime User
Hello,

I have a crash occurring very often in my application. Basically, when a user clicks on a link in the webview, in about 10 to 25% of the time, it will crash with this error:
B4X:
Program started.
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000060456ed1, pid=4392, tid=5980
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [jfxwebkit.dll+0x56ed1]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\Jo\B4J\Tests\ERRORC~1\Objects\hs_err_pid4392.log
#
# If you would like to submit a bug report, please visit:
#  http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

You can try the code I linked with this post. By clicking repeatedly on the link, it will eventually crash the application. I'm having the feeling that this crash only occurs on the x64 version of Java JDK.

A dump file is also generated, which contains more information (named "hs_err_pidxxxx.log" -> linked with this post, (extension changed to "txt" to be uploaded on the forum)).

The crash happens in one of these subs:
B4X:
Private Sub wv_LocationChanged (Location As String)
    If Location <> "" Then
        Log("location changed: " & Location)
        fx.ShowExternalDocument(Location)
        wv.LoadHtml(sHTMLContent)
    End If  
End Sub

Private Sub wv_MouseClicked (EventData As MouseEvent)
    If EventData.PrimaryButtonPressed AND EventData.ClickCount = 1 Then
        Dim mousex As Double = EventData.X    ' get the link that was clicked on page
        Dim mousey As Double = EventData.Y
        Dim Link As String
        js.enginePut("doc",we.RunMethod("getDocument",Null))
        js.evalString("var element = doc.elementFromPoint(" & mousex &","& mousey & ");") ' get the hyperlink
        Link = js.engineGet("element")
        If Link <> "" AND Link <> "[object HTMLBodyElement]" Then
            fx.ShowExternalDocument(Link)
        End If  
    End If
End Sub

Sometimes the links clicked can be webpages or network paths, so this is why I reload the HTML content every time the user clicks on a link, because I don't want to load the link in the webview.

Is there something wrong with my code, or is it a bug of JavaScriptEngine?

Thanks.
 

Attachments

  • hs_err_pid4712.txt
    29.7 KB · Views: 390
  • ErrorClickLinks.zip
    2.6 KB · Views: 287

jmon

Well-Known Member
Licensed User
Longtime User
Why don't you use LocationChanged event to catch the link?
Now that you say it... there was a reason why I had those to subs to work together, but I can't remember why. I think it was related to network paths. But it works without enabling the wv_MouseClicked sub.

It is also worth testing it with Java 8.
Ok I will test that and I'll report the results.

Thanks.
 
Upvote 0
Top