Kaju self-updater talk (v.2.x)

  1. ‹ Older
  2. last year

    Jon O

    8 Apr 2019 Testers, Xojo Pro Chicago Area USA
    Edited last year

    Hey all,

    I've come across a hiccup in Windows with Kaju and using an secure Async socket. It seems that the PageReceived event is being fired multiple times until there's a stack overflow and the program crashes. This seems possibly to be a Xojo.Net.HTTPSocket thing as opposed to a Kaju thing because the error is happening in the PageReceived event HTTPSocketAsync object which is a Xojo.Net.HTTPSocket object.

    Has anyone else seen this happen and know a workaround or cause?

    What's really odd is that, when I first fire up the program, I have Kaju check for an update in the background. It's if I initiate a manual update that this socket seems to go nuts. Again, in OS X, it's fine. I don't have a problem. Just Windows.

  3. Tim P

    8 Apr 2019 Testers, Xojo Pro Rochester, NY

    @Jon O This seems possibly to be a Xojo.Net.HTTPSocket thing as opposed to a Kaju thing because the error is happening in the PageReceived event HTTPSocketAsync object which is a Xojo.Net.HTTPSocket object.

    Has anyone else seen this happen and know a workaround or cause?

    I saw that behavior on a project, but I did not have time to stop and investigate whether it was the Kaju implementation or a Xojo framework issue. It did not happen in 2018r4 or earlier.

  4. Jon O

    8 Apr 2019 Testers, Xojo Pro Chicago Area USA

    Thanks, Tim. I've figured out how to "stop" the behavior from crashing my app, and I found a couple of spots where I don't think I was coding some things properly. When I was operating synchronously, I created my Kaju.Updater object locally in a method. Then I waited for and returned the result. When I moved to an Async connection, I added handlers to handle the async events, but I messed up by still using just a locally scoped Kaju.Updater object. So the object technically goes out of scope when the method completes, but it's held in memory because of the events still existing. I'm not sure if this was feeding the problem, but it certainly isn't good coding form!

    So I'm still going through and trying to figure if there's something I'm doing or the Xojo.Net.HTTPSocket is doing. Ideally, I'd like to update things to URLConnections and I know Kem wants to do that too, but right now, I don't know if I have time to do it myself.

  5. Kem T

    8 Apr 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    There are known bugs in HTTP socket in 2018r4 on Windows, so that might be what you're seeing.

  6. Jon O

    8 Apr 2019 Testers, Xojo Pro Chicago Area USA

    @Kem T There are known bugs in HTTP socket in 2018r4 on Windows, so that might be what you're seeing.

    OK. I have a feeling it might be. While my "out of scope" object was not good coding form, there's nothing with anything that I am doing (that I can see) that would cause the PageReceived event to fire non-stop.

  7. @Jon O OK. I have a feeling it might be. While my "out of scope" object was not good coding form, there's nothing with anything that I am doing (that I can see) that would cause the PageReceived event to fire non-stop.

    Indeed I have same issue, I'm using the Xojo.net.HTTPSocket for a simple app that controls a device to open a door and I do have another socket that checks the status of it , like a heartbeat but the problem is that some times the socket goes nuts and it kills the app after max 30 min, on Mac so far it is stable .

  8. Jon O

    8 Apr 2019 Testers, Xojo Pro Chicago Area USA

    @Aurelian N Indeed I have same issue, I'm using the Xojo.net.HTTPSocket for a simple app that controls a device to open a door and I do have another socket that checks the status of it , like a heartbeat but the problem is that some times the socket goes nuts and it kills the app after max 30 min, on Mac so far it is stable .

    OK. Well, what I have ended up doing is make sure that I remove the event handler for the socket as soon as I am done with it. This is most easily done setting up delegate methods and having a set method that you can just use to set the delegate to NIL. AddHandler and RemoveHandler work fine as well, but you have to be a little more specific with how you use them and wrap them in try/catch blocks so that you don't throw an exception if you've already removed the handler, etc.

    I've tested removing the event handlers and then adding them right back in to see if the socket is still going crazy. It isn't. Seems like as soon as the event handler is removed, the socket starts behaving itself.

  9. @Jon O OK. Well, what I have ended up doing is make sure that I remove the event handler for the socket as soon as I am done with it. This is most easily done setting up delegate methods and having a set method that you can just use to set the delegate to NIL. AddHandler and RemoveHandler work fine as well, but you have to be a little more specific with how you use them and wrap them in try/catch blocks so that you don't throw an exception if you've already removed the handler, etc.

    I've tested removing the event handlers and then adding them right back in to see if the socket is still going crazy. It isn't. Seems like as soon as the event handler is removed, the socket starts behaving itself.

    Hi Jon,

    Can you please provide an example for that ?

    I will see tomorrow the project and maybe put it somewhere , so far works nice on Mac but windows it's a nightmare .

    Thanks .

  10. Jon O

    8 Apr 2019 Testers, Xojo Pro Chicago Area USA
    Edited last year

    1.) In whatever object you have that calls the updater code, create a Delegate with the same signature as the event you want to handle (just like add handler):

    Private Sub delAsyncUpdateComplete(sender as UpdateCheckClass, result as Kaju.UpdateChecker.ResultType)

    2.) Create a property in this object of that type of delegate:

    Private Property AsyncUpdateCompleteCallBack as delAsyncUpdateComplete

    3.) Create a Handler Method for your Delegate:

    Private Sub HandleAsyncUpdateComplete(sender as UpdateCheckClass, result as Kaju.UpdateChecker.ResultType)
      If AsyncUpdateCompleteCallBack <> Nil Then
        AsyncUpdateCompleteCallBack.Invoke(Self,result)
      End If
    End Sub

    4.) Create a Set Method to set the callback for the delegate:

    Sub SetAsyncUpdateCompleteHandler(theCallback as delAsyncUpdateComplete)
      mUpdateCheckInstance.AsyncUpdateCompleteCallBack = theCallback
    End Sub

    5.) Set an initial AddHandler for the event in the constructor of your object:

    AddHandler AsyncUpdateComplete, AddressOf  HandleAsyncUpdateComplete

    Be sure to set a remove handler in your close event for the object.

    Now, wherever you want to use this update object, you can easily create a method, and set that method to be the event handler. No need to worry if AddHandler or RemoveHandler has been called. You can call do this anywhere you want:

    UpdateCheckClass.SetAsyncUpdateCompleteHandler(AddressOf UpdateCheckCompleteEvent)

    So my object that does all the checking is called UpdateCheckClass and it's actually a Singleton so I can call it anywhere in the app and I don't have to worry about instantiating it (and in the case of a Singleton, the method in step 4 is actually a Shared Method.

    My UpdateCheckComplete event has the following singature/code:

    Public Sub UpdateCheckCompleteEvent(u as UpdateCheckClass, UpdateResult as Kaju.UpdateChecker.ResultType)
    
      UpdateCheckClass.SetAsyncUpdateCompleteHandler(Nil)  // HERE IS WHERE I REMOVE THE HANDLER
     
      Select Case UpdateResult  
      Case Kaju.UpdateChecker.ResultType.Error
        MsgBox "There was an updater error."
      Case Kaju.UpdateChecker.ResultType.IgnoredUpdateAvailable
        MsgBox "There is an update available but you have chosen to ignore it."
      Case Kaju.UpdateChecker.ResultType.NoUpdateAvailable
        MsgBox "No update is available at this time."+EndOfLine+EndOfLine+"You have the most current version."
      Case Kaju.UpdateChecker.ResultType.UpdateAlreadyInProgress
        MsgBox "There is an update already in progress."
      End Select
    End Sub

    So basically as soon as the event handler method is called, I then remove it.

    I've got one more layer of an event in here from the socket that uses a traditional Add/Remove Handler directive, but I'm going to skip that. This should be enough to get you going. If not, I can try to throw my code into a project for you.

    So this is specifically for the Kaju Updater object I am working with. Your case may be a different class, but the same principles still apply. The PageReceived event of the Xojo.Net.HTTPSocket is the offending event. So I would use what I do above for that event in your HTTPSocket. It's signature is:

    Event PageReceived(url As String, httpStatus As Integer, content As String)

    So create the Delegate and necessary handler methods and callbacks with this signature and then you can add/remove the event at will in code. It's pretty cool.

  11. Tim P

    10 Apr 2019 Testers, Xojo Pro Rochester, NY

    This looks like the problem I saw, so it doesn't look like it's a Kaju problem :)
    https://forum.xojo.com/53353-net-httpsocket-pagereceived-problem

  12. Jon O

    10 Apr 2019 Testers, Xojo Pro Chicago Area USA

    Yeah, I don't think it's a Kaju thing. I posted wondering if others had seen the same or if my implementation was causing an issue. Looks like others have seen the same thing. Dale is definitely correct.

  13. Thomas R

    8 May 2019 Testers, Xojo Pro Berlin, Germany

    Hi,

    I am trying to use Kaju in my first Xojo project, but ran into a problem, I can't solve...

    Environment:
    Xojo 2019R1 on macOS 10.14.4
    Kaju 2.1

    Implemention is done completly, version set to "0.5.0" under ""Build Settings > Shared > Version" (Major Version: 0, Minor Version: 5, Bug Version: 0, Stage Code: Development, Non Release Code: 1". plist in build app shows 0.5.0 as versionstring.

    Kaju Admin is set up with correct App Name, version "0.5.1", with releasenotes, a Mac binary and a windows 64-bit binary. HTML file and binaries are uploaded to website and path and RAS Key are put into app.

    Checking for updates works fine in debug mode - Kaju finds the update from 0.5.0 to 0.5.1 and displays its update window.
    But in the build app it does not find any update. Even testing with the "WndTst" Window and manually entering all neccessary infos (URL and RSA Key) it checks the html file and says: "no update available".

    Any tips, how to solve this?

    Regards,
    Thomas

  14. Kem T

    8 May 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Just for testing, try changing the Major Version to 1 instead of 0 and see if that makes a difference. I mean in both the compiled app and the update info.

  15. Thomas R

    8 May 2019 Testers, Xojo Pro Berlin, Germany

    @Kem T Just for testing, try changing the Major Version to 1 instead of 0 and see if that makes a difference. I mean in both the compiled app and the update info.

    Perfect - I don't know why, but with a version number beginning with 1 the update is found in the compiled app.
    Thanks!

  16. Steve A

    6 Jun 2019 Little Falls, NJ

    I'm new to Kaju, but it looks like a great addition to my app.

    Unfortunately, I'm running into a problem with the Windows install. My zip file includes the VComponents files for Valentina. The log shows a failure trying to copy the vresourses folder into the install location. The relevant section of the log is below:

    "Looking for item C:\Program Files\BC Kaju Tester\vresources" 
    "...found, copying" 
    C:\Program Files\BC Kaju Tester\vresources\* 
    The system cannot find the file specified.
            0 file(s) copied.
    "...FAILED! (Error 1)" 
     "Attempting to restore old application" 

    On first glance, it appears to me that the script will not handle subfolders when copying the contents of a folder.

    Could this be the case? I created a test app that does not use Valentina and all works fine.

  17. Kem T

    6 Jun 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Could there be an invisible character in the folder name or in one of the file names that are gumming up the works? Does that folder have files in it? If you replace the contents of that folder with, say, a text file with an innocuous name, does it work? If you remove that folder but include another with an innocuous name and an innocuous file, does it work?

  18. Christoph D

    7 Jun 2019 Testers, Xojo Pro

    FWW Kagi doesn't work anymore with a 'future' macOS.
    It gives a warning the downloaded .zip file is from an unidentified developer and it does not unzip the file.
    It looks like the only way to upgrade is to use a Notarized .pkg file.

    That's a major bummer.

  19. Kem T

    7 Jun 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Ug

  20. Steve A

    7 Jun 2019 Little Falls, NJ

    @Kem T Could there be an invisible character in the folder name or in one of the file names that are gumming up the works? Does that folder have files in it? If you replace the contents of that folder with, say, a text file with an innocuous name, does it work? If you remove that folder but include another with an innocuous name and an innocuous file, does it work?

    Like

    Here is the directory structure that failed:
    -image-

    Here is what I tried:
    • I removed the Valentina files completely and the update worked as expected.

    • I created another version with the Valentina files removed and an innocuous folder with the same structure as vresourses - a folder with one subfolder containing a text file. This worked as expected.

    • I created yet another version that included the Valentina dlls but not the vresources file, and that worked.

    • I created a version that included the vresourses files, but I retyped the folder names manually to insure there were no special characters. This failed.

    The good news is that I really don't need to reinstall the Valentina files as I have no expectation they will change unless I renew my license and upgrade to a later version. They will be installed via the initial upload of my software. But it is puzzling that this folder will screw up the works.

  21. Kem T

    7 Jun 2019 Testers, Xojo Pro, XDC Speakers, MVP Connecticut

    Interesting.

    Suggestion: include this folder zipped, and have your app examine it on startup. If the installed files are missing, or you've somehow determined that the downloaded files are newer than the installed, you can install/re-install them. The switch Kaju includes when it launches your updated app can help here.

    Or you can store the hash of the zip file in your preferences and compare that on launch to see if the file has changed.

  22. Newer ›

or Sign Up to reply!