Esri / offline-editor-js

ArcGIS JavaScript library for handling offline editing and tiling.
http://esri.github.io/offline-editor-js/demo/
Apache License 2.0
159 stars 142 forks source link

Download tiles performance #486

Closed saif984 closed 6 years ago

saif984 commented 7 years ago

i had change for download tiles method, to download up to 40 tile simultaneously and it show big difference in downloading tiles time, code to be as follows: `_doNextTile: function (i, cells, reportProgress) { var cell = cells[i];

        var url = this._getTileUrl(cell.level, cell.row, cell.col);
        if (url.indexOf('#') != 0) {
            this._tilesCore._storeTile(url, this.offline.proxyPath, this.offline.store, function (success, error) {
                if (!success) {
                    ////console.log("error storing tile", cell, error);
                    error = { cell: cell, msg: error };
                }
                var cancelRequested = reportProgress({ countNow: ++this.FinishDownloaded, countMax: cells.length, cell: cell, error: error, finishedDownloading: false });

                var li = this.LastTileInfoIndex;
                this.LastTileInfoIndex = null
                if (li != null) {
                    this._doNextTile(li + 1, cells, reportProgress);
                }
                if (cancelRequested || this.FinishDownloaded === cells.length) {
                    reportProgress({ finishedDownloading: true, cancelRequested: cancelRequested });
                }

            }.bind(this));
        }
        else {

            var cancelRequested = reportProgress({ countNow: ++this.FinishDownloaded, countMax: cells.length, cell: cell, finishedDownloading: false });
            var li = this.LastTileInfoIndex;
            this.LastTileInfoIndex = null
            if (li != null) {
                this._doNextTile(li + 1, cells, reportProgress);
            }
            if (cancelRequested || this.FinishDownloaded === cells.length) {
                reportProgress({ finishedDownloading: true, cancelRequested: cancelRequested });
            }

        }
        if (i < cells.length - 1) {
            if (i - this.FinishDownloaded > 40) {
                this.LastTileInfoIndex = i;
            }
            else
                this._doNextTile(i + 1, cells, reportProgress);
        }

    }`

and made change to this

prepareForOffline : function(minLevel, maxLevel, extent, reportProgress) { this.FinishDownloaded = 0; this._tilesCore._createCellsForOffline(this,minLevel,maxLevel,extent,function(cells){ /* launch tile download */ this._doNextTile(0, cells, reportProgress); }.bind(this)); }

andygup commented 7 years ago

Thanks @saif984! Makes sense since the current code is a single threaded loop.

Was the app useable during the concurrent download requests?

saif984 commented 7 years ago

No, in my app it's disabled till downloads finished by business prespectives

andygup commented 6 years ago

Closing.