braydel / open-webkit-sharp

Automatically exported from code.google.com/p/open-webkit-sharp
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Offline Application in OWKS #145

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I've been bashing my head against this for almost a week now, and while I've 
made some progress, I feel as if my lack of experience working with browsers 
and web coding in general (I really have 0 experience with this) has led me as 
far as I can get in a reasonable amount of time.

As can be guessed from the title, I am attempting to enable offline 
applications in a basic OWKS browser.  This storage aspect of this has been 
rather simple to fix.  Included in WebKit preferences is the flag 
offlineWebApplicationCacheEnabled along with the method 
setOfflineWebApplicationCacheEnabled().  Enabling this feature in OWKS was as 
simple as creating a boolean and the following function in GlobalPreferences.cs:

private Boolean offlineWebApplicationCacheEnabled;

[Browsable(true), Category("Behavior"), 
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Description("Specifies whether offline application caching is enabled.")]
public bool setOfflineWebApplicationCacheEnabled
{
    get {
        return offlineWebApplicationCacheEnabled;
    }
    set {
        try{
            preferences.setOfflineWebApplicationCacheEnabled(Convert.ToInt32(value));
            offlineWebApplicationCacheEnabled = value;
        }catch{}
    }
}

And voila caching works.  I'm quite certain it is working because caching an 
application using a simple OWKS browser and then inserting the resulting 
ApplicationCache.db (it's cached as an sq3lite database) into Safari's local 
database storage will run the application offline perfectly.  There is no such 
equivalent luck running the simple browser offline, though the application runs 
perfectly while online (connected to the internet).

I believe I may have pinpointed the problem: javascript isn't being executed 
offline.   After traversing the DOM trees of the online rendered page and the 
offline rendered page, I found some iframes missing, all of which are created 
and inserted into the tree via javascript calls.  Presumably, this means these 
calls aren't being made.  However, javascript has been enabled, and I am thus 
at a loss as to why this isn't working.

Any help would be appreciated, my apologies if this is a simple question and/or 
should not have been posted here.

Original issue reported on code.google.com by WazzieLo...@gmail.com on 11 Oct 2012 at 3:02

GoogleCodeExporter commented 8 years ago
Update: It's not a javascript issue, javascript is running just fine.  There's 
seems to be something wrong with resource loading.  The following is what 
happened:

Initial navigation to the page while offline results in the loading of the 
cached html page.  However, no javascript is executed.  OWKS attempts to 
contact the remote server to check for an updated manifest, fails because there 
is no internet connection.  It then attempts to load the next resource.  
However, instead of loading from the cache storage, it attempts to load the 
resource from the remote server.  This fails because there is not internet 
connection and nothing more is done.

Curiously enough, reloading the page (calling WebKitBrowser.reload(), note that 
calling window.location.reload will not change anything) will cause the 
resource to be loaded from the local application cache.  However, subsequent 
resources requests are also directed to the remote server and fail with the 
same message, internet connection is offline.  Reloading again will cause these 
resources to be loaded from the local application cache.

Basically, each reload seems to direct OWKS to load the next level of nested 
resources from the cache, and any resources nested within these will fail as 
OWKS attempts to load them from the remote server.  Repeat until everything has 
been loaded from the local application cache.

What could be causing this weird switch between attempting to load from remote 
server and then loading from the application cache, and how do I instruct OWKS 
to load all nested resources from the cache as well?

Original comment by WazzieLo...@gmail.com on 16 Oct 2012 at 10:28