HTMLViewer.LoadURL causes "Quit Unexpectedly" crash

Hi all,

I have an app that uses an HTMLViewer to load a page every 10 seconds checking for updated data. It runs fine for about 5 hours, then the .LoadURL command crashes a-la:

The only way I was even able to determine this was to literally append to a text file after EVERY LINE OF CODE, which was exhausting to set up.

Where is the error occurring? And, more importantly, how can I catch and handle this error rather than crashing?

The whole crash log would be more useful. Paste it over at pastebin.com
Guessing, based on the name of your app, that you don’t need a whole HTML Viewer to check for metadata changes. You’d be much more efficient using a socket.

file a bug report with the entire crash log attached

Thanks for the replies guys… Is there anything I can do to catch the crash in the HTMLViewer object other than waiting for a fix in Xojo?

[quote=261376:@Tim Parnell]The whole crash log would be more useful. Paste it over at pastebin.com
Guessing, based on the name of your app, that you don’t need a whole HTML Viewer to check for metadata changes. You’d be much more efficient using a socket.[/quote]

Thanks, will do next time I have time to wait for it to crash (probably over the weekend). And sadly, I do need the HTML Viewer. There are dozens and dozens of cookies that are calculated by javascript on this crazily secure internal corporate site. If you miss one of them you don’t get the right data back.

Thanks!

[quote=261498:@Christian Wheel]Thanks for the replies guys… Is there anything I can do to catch the crash in the HTMLViewer object other than waiting for a fix in Xojo?
[/quote]
Since this is a hard crash way down deep in what looks like an Apple supplied component (webCore) it’s not likely
But the crash log might point out some way to avoid this

Why not have 2 htmlviewers or htmlviewer-based-class instances and, using your timer, switch each hour, destroying the “old” one and recreating it? Or something like that - middle of the night here and not thinking entirely clearly. :wink:

[quote=261498:@Christian Wheel]Thanks, will do next time I have time to wait for it to crash (probably over the weekend). And sadly, I do need the HTML Viewer. There are dozens and dozens of cookies that are calculated by javascript on this crazily secure internal corporate site. If you miss one of them you don’t get the right data back.
[/quote]
You can find crash logs by using the Console.app in your utilities folder.

Also, if your corporate site considers javascript secure there’s another whole problem :stuck_out_tongue:
(one time the Google bot deleted a US gov’t website that was “secured” by JavaScript)

[quote=261500:@Norman Palardy]Since this is a hard crash way down deep in what looks like an Apple supplied component (webCore) it’s not likely
But the crash log might point out some way to avoid this[/quote]

Agreed. I don’t think Apple expected you’d be calling a Java intensive web page to reload every 10 seconds for 5 hours or more. I wonder if I wrote an AppleScript to do that in Safari, if Safari would crash after 5 hours?

I was just thinking about that as a valid way of alleviating the issue. If for some reason this is a leak that messes up the app itself, though, the damage maybe done. But by the same token, relaunching the app itself would do the trick. 10 seconds is an eternity to do so.

To be fair, Internet Explorer handles it without a problem when I run the app on Windows. Been running for over 72 hours now without any issues.

That is the beauty of different platforms. They react differently. You should really consider trying Peter’s idea of destroying instances of the HTMLViewer regularly to clean what appears to be a cumulative effect. Closing and opening the window again would do that easily.

Keep in mind that this could simply be an OutOfMemory situation. Have you tried compiling the Mac version as 64-bit?

I think I figured out the cause of this. I’m using this code to get the source of the HTML as a string:

Sub DocumentComplete(URL as String) me.ExecuteJavaScript "window.status = document.getElementsByTagName('html')[0].innerHTML;" End Sub

Sub StatusChanged(newStatus as String) GlobalHTML = newStatus End Sub

It’s the javascript execution that causes the crash.

[quote=262546:@Christian Wheel]I think I figured out the cause of this. I’m using this code to get the source of the HTML as a string:

Sub DocumentComplete(URL as String) me.ExecuteJavaScript "window.status = document.getElementsByTagName('html')[0].innerHTML;" End Sub

Sub StatusChanged(newStatus as String) GlobalHTML = newStatus End Sub

It’s the javascript execution that causes the crash.[/quote]yeah, that’s too much data to put in Status.

Is there a better way to get the source of the page?

Thanks!

MBS has a class for that. See https://forum.xojo.com/30522-htmlviewer-get-page-source/0

Otherwise, you could divide the source and send it in smaller chunks.

I will probably end up purchasing MBS once I’m able to save up for it, if not only for the increased functionality, simply for the incredibly impressive volume of work that has gone into it. It certainly deserves to be supported!

Although for this case, a “get source” method should probably be built into the Xojo class. It seems like that’s some fairly basic functionality that the HTMLViewer is missing.

<https://xojo.com/issue/43625>

I would really recommend you learn how to handle the cookies for this particular case and use a HTTP Socket. It would use less resources and be more efficient.

While I agree that’s the best approach, the cookie encryption is handled in a (closed source) flash movie, so an HTTP Socket is not going to be possible in this case.

There is a feature request for access to the page source that dates back to 2008 : <https://xojo.com/issue/1205>

That does not give much hope to have that feature before long.

This works without overwhelming Status :

[code]Sub Action()
dim js as string

js = js + “var source = document.getElementsByTagName(‘html’)[0].innerHTML;”
js = js + "var chunks = source.split(’>’); "
js = js + "for (i = 0; i < chunks.length; i++) { "
js = js + “window.status = chunks[i]+’>’; }”

HTMLViewer1.ExecuteJavaScript(js)
End Sub
[/code]

Sub StatusChanged(newStatus as String) TextArea1.Text = TextArea1.Text+newStatus End Sub