To get to the point, within the WebThread, I’m having an issue when I use WebContainer.EmbedWithin which is resulting as a Javascript Null Is Not an Object error. It’ll work a random number of times and then I’ll get this:
@Hal Gumbert - Just running your project I am getting a ThreadAlreadyRunning exception in your DetailLoad method. This means that you’re calling Run on a thread that you’ve previously called it before letting it finish. You should be checking the state of the Thread before calling Run on it again.
The only time I’m getting that error is when I get that exception. It’s from the app trying to update a control that doesn’t exist because of the exception.
Just to rewind a bit, my only reason for using WebThreads and previously WebTimers is to show a spinner and disable controls while my code runs. If there was a call I could make to update the UI during the round trip to the server, I’d be all for it and wouldn’t need WebThreads as my code runs without errors when I take WebThreads and WebTimers out of the equation. Stepping even further back, if WebListboxes could show containers in the rows like iOSTable, I don’t think I’d need scrolling containers.
I took your advice and updated my calling of “DetailLoadDoThread.Run” to check for the thread state. I also added a boolean property as an extra measure. The following is what my ContactsPage.DetailLoad method looks like. This method is the only place I run the WebThread.
[code] If DetailLoadFlag Then
return
end if
DetailLoadFlag = true
If DetailLoadDoThread.State = DetailLoadDoThread.NotRunning Then
SpinnerUpdate( "Show" )
If true Then
// Run the WebThread
DetailLoadDoThread.Run
Else
// Run same code as the WebThread
DetailSave
DetailLoadDo
SpinnerUpdate( "Hide" )
DetailLoadFlag = false
End If
End [/code]
I’ve tried 2016r3 and 2016r4b4. Both result in the same problem. It doesn’t happen every time I click on a contact, but definitely 20 or less clicks. Usually less than 8 clicks.
I just tried the beta from today and I’m getting “Could not execute returned javascript: null is not an object (evaluating ‘this.object().children’)” when I use a WebThread.
If I run the same code without the WebThread, it works fine.
Are you able to reproduce the errors that I show in my vid/project linked three posts above this post?[/quote]
I’ve been looking at this a little every day, mostly to see if I can come up with a way to reliably reproduce it on every click. So far nothing has jumped out at me.
So I just did a line-level analysis of this app, trying to figure out what’s going on. The javascript error you’re getting is because there are commands being sent to the browser for one type of control when the control on the browser is of a different type. (commands are for a Button, but the control is actually a popupMenu). I’m guessing that the framework is reusing control IDs too soon and when a user clicks through these items quickly, things get very confused. I’m looking into adding an expiration date to the cache so control IDs will take longer to expire.
Also, if you look in Xanadu.ListboxCellLoad, you’re pushing the results of CacheListBoxJS into an array that you use later. That could cause problems in this same scenario because the javascript you’re creating is specific to a particular control ID. You at least need to add a bit of code to make sure tbody exists before using it.
Wow! That’s super low level and difficult to find. You and Xojo freaking rock! I’d love to test it out when you think you have it squashed.
The CacheListBoxJS isn’t being used anymore or shouldn’t be. I was using that to inject images in a listbox cell. I’ll update Xanadu in GitHub this morning where that code is ripped out.