Search code examples
androidhtmlnetwork-programmingcrosswalk-runtimewebviewchromium

How to know when Chromium has stopped making network requests?


We are working with HTML5 games we need to know when a game has completely finished downloading all it's assets. In case of HTML5, this is not the same as when the page finishes loading. After the page finishes loading, the game's assets are downloaded.

We are running these games in a native app in which we have embedded the Crosswalk webview. The Crosswalk-project is based on the Chromium project, so chances are what works for Chromium will work for Crosswalk too. How do I find out when the browser has completely stopped making network requests and has basically stopped all communication with the internet?


Solution

  • There is a great addon for Google Chrome called Live Http Headers. It's also available for Firefox.

    You can get the addon for Google Chrome here.

    It will capture each request your browser is making and show you the headers and status codes: enter image description here

    If you are on Linux you can also monitor network usage by application using nethogs but not as detailed as Live Http Headers.

    apt-get update
    apt-get install nethogs
    nethogs eth0
    

    You could also monitor traffic on port 80:

    tshark -i eth0 -f "port 80"
    

    Alternatively you can use Wireshark instead of the command line version and you can get that here it works on Windows, Mac, and Linux.

    Here is an example filter in Wireshark: enter image description here

    A more permanent solution as you requested in the comments is to put a device directly in line with your device running the application and use tcpdump:

    sudo tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'
    

    This will show the get, response, and payload and should be plenty information for debugging. Add the -i option to specify the interface. A computer to share it's network connection between two network interface cards would work great for this.

    Hope this helps.

    --lillypad