Html5 and life updates error

I try use live updates in my game. I do this steps:

  • Set live updates to zip-mode
  • Publish html5 application with live update content
  • unpack defold.resourcepack_js-web_XXX.zip in updates folder near index.html
  • pack index.html+bundles in index.zip and upload to itch.io or games.yandex.ru

I have following errors on some browser and devices. Sometimes all ok

I heve this code for upload missing bundles:

public function loadCollectionProxy(name: String, collectionProxy: Url, enableOnFinish: Bool) {
        var missing = Collectionproxy.missing_resources(collectionProxy);
        var pending = 0;
        
        function checkPendings() {
                if (pending == 0) {
                        trace('Start load collection ${name}');
                        Msg.post(collectionProxy, CollectionproxyMessages.load);
                } else {
                        trace('Collection proxy ${name} pending for ${pending}');
                }
        }

        var manifest = Resource.get_current_manifest();

        PairTools.pairsEach(missing, function(_, hash) {                        
                pending++;                        
                var url = './updates/${hash}';

                trace('Request ${url}');
                Http.request(url, "GET", function(_, _, resp) {
                        trace('Responce ${url} ${resp.status}');
                        if (resp.status == 200 || resp.status == 304) {                                        
                                Resource.store_resource(manifest, resp.response, hash, function(_, _, status) {
                                        trace('Resource stored ${hash} ${status}');
                                        if (status) {
                                                pending--;
                                                checkPendings();
                                        } else {
                                                ErrorPopup.display('Error store resource ${url}');
                                        }
                                });
                        } else {
                                ErrorPopup.display('Error load resource ${url}');
                        }
                });
        });                

        var status = { done: false };
        _tasks.push(CoTask.LoadCollectionProxy(name, collectionProxy, enableOnFinish, status));

        checkPendings();

        while (!status.done) {
                Coroutine.yield();
        }
}

I think that the problem is related to the issue https://github.com/defold/defold/issues/7233 (I filled it just now). It’s hard to read the code but I see that it starts downloading all resources simultaneously, finishes it in the random order and, therefore, calls resource.store_resource in the random order, too. I’m not sure but it looks like the order is important. Plus, you should call resource.store_resource and wait for the result, then call resource.store_resource for the next resource, etc.

P.S. Is it Haxe?

I change my code to keep call order of store_resource but nothing changed =(

I maked project to reproduce my problem.

I experement with it and find problem in file zone/zone_0001_rio/rio_bg.png. If exclide it from build, the the problem disappears

1 Like