AllanWang / Frost-for-Facebook

An extensive and functional third party app for Facebook
https://allanwang.github.io/Frost-for-Facebook/
GNU General Public License v3.0
1.09k stars 85 forks source link

Improve indication of failing images in messages #1468

Closed mikini closed 5 years ago

mikini commented 5 years ago

Describe the bug Details contains snippet from auto bugreport request. Received an image in a Messenger message. It didn't display in the thread view just showed as empty space. When clicked showed again as empty space and when attempting to download a red exclamation mark is shown. The request to post a bugreport popped up when ckicking the error.

Root cause of image not showing is obviously Facebook not serving it. But the missing image data could be indicated to the user already in the thread view. I guess "unsuccessful response" refers to HTTP status code, like a 404?

Screenshots available on demand.

Thanks for frost.

Details (please provide at least the app version): OS Version: 3.18.91-14843133-QB22457191 (G930FXXS4ESC3) OS SDK: 26 Device (Manufacturer): herolte (samsung) Model (Product): SM-G930F (heroltexx) Package Installer: com.google.android.packageinstaller Tablet: false Screen Dimensions: 1440 x 2560

App: com.pitchedapps.frost App Version Name: 2.2.4 App Version Code: 2020400

Url: https://scontent-arn2-1.xx.fbcdn.net/v/t1.15752-9/fr/cp0/e15/q65/65741300_324235121858824_9056594634230202368_n.jpg?_nc_cat=110&efg=eyJpIjoidCJ9&_nc_oc=AQkp36H-LPsWVWiAszt5Au11vTbt2OL06kcmE4tfok1k1bqkPjzMRaX7QPiLC0r5rGE&_nc_ht=scontent-arn2-1.xx&oh=2b2ae1918e72b915e99359ebff3b344d&oe=5D8020C6 Message: Unsuccessful response for image: <!DOCTYPE html>

Facebook | Error
AllanWang commented 5 years ago

I can add it. I'll have to look at the response for such images in greater detail, but I think you've provided me with enough info

mikini commented 5 years ago

Would be a nice addition, bug or not ;).

As an additional aid, here is a HAR dump of the image request receiving a 503 done from a Firefox profile on which the account is logged into Facebook. Whether there is a session or not doesn't, however, seem to affect the response in this specific situation as can be seen from the similar response to the wget request below it (and wget even misrepresents it as "no server available").

(Strangely enough, the server around 21:10 UTC started responding with status 200, and at the moment the image is served even to the wget request. Are such content urls state/sessionless?)

HAR:

{
  "log": {
    "version": "1.2",
    "creator": {
      "name": "Firefox",
      "version": "67.0.4"
    },
    "browser": {
      "name": "Firefox",
      "version": "67.0.4"
    },
    "pages": [
      {
        "startedDateTime": "2019-07-03T22:59:42.788+02:00",
        "id": "page_3",
        "pageTimings": {
          "onContentLoad": 272,
          "onLoad": 314
        }
      }
    ],
    "entries": [
      {
        "pageref": "page_3",
        "startedDateTime": "2019-07-03T22:59:42.788+02:00",
        "request": {
          "bodySize": 0,
          "method": "GET",
          "url": "https://scontent-arn2-1.xx.fbcdn.net/v/t1.15752-9/fr/cp0/e15/q65/65741300_324235121858824_9056594634230202368_n.jpg?_nc_cat=110&efg=eyJpIjoidCJ9&_nc_oc=AQkp36H-LPsWVWiAszt5Au11vTbt2OL06kcmE4tfok1k1bqkPjzMRaX7QPiLC0r5rGE&_nc_ht=scontent-arn2-1.xx&oh=2b2ae1918e72b915e99359ebff3b344d&oe=5D8020C6",
          "httpVersion": "HTTP/2.0",
          "headers": [
            {
              "name": "Host",
              "value": "scontent-arn2-1.xx.fbcdn.net"
            },
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
            },
            {
              "name": "Accept",
              "value": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
            },
            {
              "name": "Accept-Language",
              "value": "en,en-US;q=0.7,da;q=0.3"
            },
            {
              "name": "Accept-Encoding",
              "value": "gzip, deflate, br"
            },
            {
              "name": "DNT",
              "value": "1"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            },
            {
              "name": "Upgrade-Insecure-Requests",
              "value": "1"
            },
            {
              "name": "Pragma",
              "value": "no-cache"
            },
            {
              "name": "Cache-Control",
              "value": "no-cache"
            }
          ],
          "cookies": [],
          "queryString": [
            {
              "name": "_nc_cat",
              "value": "110"
            },
            {
              "name": "efg",
              "value": "eyJpIjoidCJ9"
            },
            {
              "name": "_nc_oc",
              "value": "AQkp36H-LPsWVWiAszt5Au11vTbt2OL06kcmE4tfok1k1bqkPjzMRaX7QPiLC0r5rGE"
            },
            {
              "name": "_nc_ht",
              "value": "scontent-arn2-1.xx"
            },
            {
              "name": "oh",
              "value": "2b2ae1918e72b915e99359ebff3b344d"
            },
            {
              "name": "oe",
              "value": "5D8020C6"
            }
          ],
          "headersSize": 656
        },
        "response": {
          "status": 503,
          "statusText": "Service Unavailable",
          "httpVersion": "HTTP/2.0",
          "headers": [
            {
              "name": "content-length",
              "value": "2959"
            },
            {
              "name": "content-type",
              "value": "text/html; charset=utf-8"
            },
            {
              "name": "access-control-allow-origin",
              "value": "*"
            },
            {
              "name": "x-fb-response-reason",
              "value": "No server is available for the request"
            },
            {
              "name": "date",
              "value": "Wed, 03 Jul 2019 20:59:42 GMT"
            },
            {
              "name": "X-Firefox-Spdy",
              "value": "h2"
            }
          ],
          "cookies": [],
          "content": {
            "mimeType": "text/html; charset=utf-8",
            "size": 2959,
            "text": "<!DOCTYPE html>\n<html lang=\"en\" id=\"facebook\">\n  <head>\n    <title>Facebook | Error</title>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"cache-control\" content=\"no-cache\">\n    <meta http-equiv=\"cache-control\" content=\"no-store\">\n    <meta http-equiv=\"cache-control\" content=\"max-age=0\">\n    <meta http-equiv=\"expires\" content=\"-1\">\n    <meta http-equiv=\"pragma\" content=\"no-cache\">\n    <meta name=\"robots\" content=\"noindex,nofollow\">\n    <style>\n      html, body {\n        color: #141823;\n        background-color: #e9eaed;\n        font-family: Helvetica, Lucida Grande, Arial,\n                     Tahoma, Verdana, sans-serif;\n        margin: 0;\n        padding: 0;\n        text-align: center;\n      }\n\n      #header {\n        height: 30px;\n        padding-bottom: 10px;\n        padding-top: 10px;\n        text-align: center;\n      }\n\n      #icon {\n        width: 30px;\n      }\n\n      h1 {\n        font-size: 18px;\n      }\n\n      p {\n        font-size: 13px;\n      }\n\n      #footer {\n        border-top: 1px solid #ddd;\n        color: #9197a3;\n        font-size: 12px;\n        padding: 5px 8px 6px 0;\n      }\n    </style>\n  </head>\n  <body>\n    <div id=\"header\">\n      <a href=\"//www.facebook.com/\">\n        <img id=\"icon\" src=\"//static.facebook.com/images/logos/facebook_2x.png\" />\n      </a>\n    </div>\n    <div id=\"core\">\n      <h1 id=\"sorry\">Sorry, something went wrong.</h1>\n      <p id=\"promise\">\n        We're working on it and we'll get it fixed as soon as we can.\n      </p>\n      <p id=\"back-link\">\n        <a id=\"back\" href=\"//www.facebook.com/\">Go Back</a>\n      </p>\n      <div id=\"footer\">\n        Facebook\n        <span id=\"copyright\">\n          &copy; 2019\n        </span>\n        <span id=\"help-link\">\n          &#183;\n          <a id=\"help\" href=\"//www.facebook.com/help/\">Help Center</a>\n        </span>\n      </div>\n    </div>\n    <script>\n      document.getElementById('back').onclick = function() {\n        if (history.length > 1) {\n          history.back();\n          return false;\n        }\n      };\n\n      // Adjust the display based on the window size\n      if (window.innerHeight < 80 || window.innerWidth < 80) {\n        // Blank if window is too small\n        document.body.style.display = 'none';\n      };\n      if (window.innerWidth < 200 || window.innerHeight < 150) {\n        document.getElementById('back-link').style.display = 'none';\n        document.getElementById('help-link').style.display = 'none';\n      };\n      if (window.innerWidth < 200) {\n        document.getElementById('sorry').style.fontSize = '16px';\n      };\n      if (window.innerWidth < 150) {\n        document.getElementById('promise').style.display = 'none';\n      };\n      if (window.innerHeight < 150) {\n        document.getElementById('sorry').style.margin = '4px 0 0 0';\n        document.getElementById('sorry').style.fontSize = '14px';\n        document.getElementById('promise').style.display = 'none';\n      };\n    </script>\n  </body>\n</html>\n"
          },
          "redirectURL": "",
          "headersSize": 249,
          "bodySize": 3208
        },
        "cache": {},
        "timings": {
          "blocked": 20,
          "dns": 31,
          "connect": 15,
          "ssl": 19,
          "send": 0,
          "wait": 15,
          "receive": 0
        },
        "time": 100,
        "_securityState": "secure",
        "serverIPAddress": "31.13.72.12",
        "connection": "443"
      }
    ]
  }
}

Wget:

$ wget --server-response "https://scontent-arn2-1.xx.fbcdn.net/v/t1.15752-9/fr/cp0/e15/q65/65741300_324235121858824_9056594634230202368_n.jpg?_nc_cat=110&efg=eyJpIjoidCJ9&_nc_oc=AQkp36H-LPsWVWiAszt5Au11vTbt2OL06kcmE4tfok1k1bqkPjzMRaX7QPiLC0r5rGE&_nc_ht=scontent-arn2-1.xx&oh=2b2ae1918e72b915e99359ebff3b344d&oe=5D8020C6"
--2019-07-03 23:01:38--  https://scontent-arn2-1.xx.fbcdn.net/v/t1.15752-9/fr/cp0/e15/q65/65741300_324235121858824_9056594634230202368_n.jpg?_nc_cat=110&efg=eyJpIjoidCJ9&_nc_oc=AQkp36H-LPsWVWiAszt5Au11vTbt2OL06kcmE4tfok1k1bqkPjzMRaX7QPiLC0r5rGE&_nc_ht=scontent-arn2-1.xx&oh=2b2ae1918e72b915e99359ebff3b344d&oe=5D8020C6
Resolving scontent-arn2-1.xx.fbcdn.net (scontent-arn2-1.xx.fbcdn.net)... 31.13.72.12, 2a03:2880:f00a:e:face:b00c:0:3
Connecting to scontent-arn2-1.xx.fbcdn.net (scontent-arn2-1.xx.fbcdn.net)|31.13.72.12|:443... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 503 No server is available for the request
  Content-Type: text/html; charset=utf-8
  Access-Control-Allow-Origin: *
  Date: Wed, 03 Jul 2019 21:01:38 GMT
  Connection: close
  Content-Length: 2959
2019-07-03 23:01:38 ERROR 503: No server is available for the request.

$ 
AllanWang commented 5 years ago

I added a small snippet to close the image activity if it isn't found.

I can't change the message thread ui easily since that's currently just a webview.

For errors, using the response code would be nicer but I'm currently passing the uri to the library only.

AllanWang commented 5 years ago

scontent urls typically don't require sessions