Using ShowURL to download WebFile causes WebApp to reload sometimes (Safari)

  1. 5 weeks ago

    Michael D

    Sep 17 Pre-Release Testers, Xojo Pro

    I have a simple WebApp which lets a user upload a file.

    On the final confirmation page, there is a button to download the file again (so they can get acopy of what they uploaded). The code in the button looks like this:

    PushButton1.Acion
      if fDownload <> nil then
        dim inNewWindow as boolean = False
        ShowURL fDownload.URL, inNewWindow ' this causes the file to be downloaded  ### fDownload is a property of the WebPage
      end if

    When the user clicks this button, the file is always downloaded.

    However, sometimes I also see this incorrect behavior:

    • App.DisconnectMessage is shown (briefly, for perhaps 1/2 second)
    • The WebApp reloads - a check of the log shows that a request to "/" is being made. Here is an example from the log. In this case, I clicked the Download button twice. The first time it worked normally, but on the second click the app restarted:
    ### The next line shows the download happening normally when I click the Download button:
    
    10.0.32.1 - - [17/Sep/2019:07:13:46 -0700] "GET /90B2D84D280DA0079C1838995D76BBA7E72115F1/files/8869-6696-6169-3073-0214/username-12345-2019-09-17T07-13-43.pzfx HTTP/1.1" 200 22217 "-" "keep-alive"
    
    
    ### I don't know what this line is - some sort of event action?
    
    10.0.32.1 - - [17/Sep/2019:07:13:52 -0700] "POST /90B2D84D280DA0079C1838995D76BBA7E72115F1/comm/event/IphS8w9a.Action HTTP/1.1" 200 148 "-" "application/x-www-form-urlencoded"
    
    
    ### I click the download button a second time:
    
    10.0.32.1 - - [17/Sep/2019:07:13:52 -0700] "GET /90B2D84D280DA0079C1838995D76BBA7E72115F1/files/8869-6696-6169-3073-0214/username-12345-2019-09-17T07-13-43.pzfx HTTP/1.1" 200 22217 "-" "keep-alive"
    
    
    ### These line seem to correspond to App.DisconnectMessage being shown, and the WebApp reloading from scratch:
    
    10.0.32.1 - - [17/Sep/2019:07:13:57 -0700] "GET / HTTP/1.1" 200 3028 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /9E18A7A1D203B8155F7CDB13EBACF7341E9DE9B9/styles.css HTTP/1.1" 200 22558 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /framework/framework.js HTTP/1.1" 304 269 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /framework/appicon128.png HTTP/1.1" 304 271 "-" "br, gzip, deflate"
    [... etc ... ]
    

    Running in the Safari 12.1.2 debugger I see this Error:

    [Error] Failed to load resource: Frame load interrupted (username-12345-2019-09-17T07-13-43.pzfx , line 0)

    Any idea why this is happening?

    The problem seems to have gone away, so I'm going to mark this as solved:

    • Perhaps it was some sort of Safari Caching bug since I updated my webApp from Xojo2018 to Xojo 2019R1.1
    • Perhaps setting WebFile.MimeType to "application/octet-stream" did solve the problem, but Safari was caching the old file?

    I'll update if it recurs.

  2. Michael D

    Sep 17 Pre-Release Testers, Xojo Pro

    More info:

    • I tried changing WebFile.MimeType to "application/octet-stream" but this had no effect. WebFile.ForceDownload was already 'true'
    • Googling for Safari issues, I see a lot of comments about this happening in Safari 10, but it sounds like a bug that was fixed a couple years ago.
    • I tested in Chrome, and don't see the issue.
  3. Greg O

    Sep 17 Xojo Inc
    Edited 5 weeks ago

    I don't see anything out of the ordinary here...

    ### I don't know what this line is - some sort of event action?

    10.0.32.1 - - [17/Sep/2019:07:13:52 -0700] "POST /90B2D84D280DA0079C1838995D76BBA7E72115F1/comm/event/IphS8w9a.Action HTTP/1.1" 200 148 "-" "application/x-www-form-urlencoded"

    This is what happens whenever a user clicks a button. it's the "Action" event of the button being sent from the browser to the app

    10.0.32.1 - - [17/Sep/2019:07:13:46 -0700] "GET /90B2D84D280DA0079C1838995D76BBA7E72115F1/files/8869-6696-6169-3073-0214/username-12345-2019-09-17T07-13-43.pzfx HTTP/1.1" 200 22217 "-" "keep-alive"

    Both of these look correct. The browser is requesting the file and the response was ~22K.

    ### These line seem to correspond to App.DisconnectMessage being shown, and the WebApp reloading from scratch:

    10.0.32.1 - - [17/Sep/2019:07:13:57 -0700] "GET / HTTP/1.1" 200 3028 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /9E18A7A1D203B8155F7CDB13EBACF7341E9DE9B9/styles.css HTTP/1.1" 200 22558 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /framework/framework.js HTTP/1.1" 304 269 "-" "br, gzip, deflate"
    10.0.32.1 - - [17/Sep/2019:07:13:58 -0700] "GET /framework/appicon128.png HTTP/1.1" 304 271 "-" "br, gzip, deflate"
    [... etc ... ]

    Correct. Every time a browser connects, it requests the root "/" and the returned page requests styles.css and framework.js. When framework.js is run, it requests appicon128.png.

    Running in the Safari 12.1.2 debugger I see this Error:
    [Error] Failed to load resource: Frame load interrupted (username-12345-2019-09-17T07-13-43.pzfx , line 0)

    This would seem to indicate that the backend went away in the middle of the request.

    Is it possible that your web app is outright crashing?

  4. Greg O

    Sep 17 Xojo Inc

    @Michael D More info:

    • I tried changing WebFile.MimeType to "application/octet-stream" but this had no effect. WebFile.ForceDownload was already 'true'
    • Googling for Safari issues, I see a lot of comments about this happening in Safari 10, but it sounds like a bug that was fixed a couple years ago.
    • I tested in Chrome, and don't see the issue.

    One difference between browsers is that we use ServerEvents instead of a push when they're available. For the most part this means Safari and Safari on iOS, so it could be related to that. That said, I've not heard of users having trouble with Safari in a very long time.

  5. Michael D

    Sep 17 Pre-Release Testers, Xojo Pro

    More info:

    • the WebApp is not crashing.
    • I have logging the app.unhandledException event and am not seeing anything there
    • this happens both in the IDE debugger as well as a built stand-alone app using SSL
    • I realized I was using GhosteryLite on Safari, but I still see the behavior even when Ghostery is disabled.
    • The Safari console errors "Failed to load resource: Frame load interrupted (username-12345-2019-09-17T07-13-43.pzfx , line 0)" have no relationship to anything: the file still downloads, and I see the error regardless of whether the page reloads or not

    Even more Info:

    • I did nothing other than re-build and re-deploy the web app, and now suddenly it's working!
    • Could this be some weird javascript framework / caching bug?
  6. Michel B

    Sep 17 Pre-Release Testers, Xojo Pro RubberViews.com

    You could replace ShowURL by a link for the user to click on to start download.

  7. Michael D

    Sep 17 Pre-Release Testers, Xojo Pro Answer

    The problem seems to have gone away, so I'm going to mark this as solved:

    • Perhaps it was some sort of Safari Caching bug since I updated my webApp from Xojo2018 to Xojo 2019R1.1
    • Perhaps setting WebFile.MimeType to "application/octet-stream" did solve the problem, but Safari was caching the old file?

    I'll update if it recurs.

or Sign Up to reply!