electron-userland/electron-builder

download-progress does not emit proper values (nsis-web, differentialPackage)

kukiel opened this issue Β· 33 comments

I have problem with update events when using nsis-web. The thing is that download-progress event is only taking into consideration the .exe file which is 500KB and when I want to display some progressbar it is downloading 500KB and showing instantly 100%. After that it is downloading 7z file in the background and I cannot see progress of it - this is bad especially as I plan to have large files included in app.

package.json

  "scripts": {
    "publish": "build --x64 --ia32 --windows nsis-web -p always"
  },
  "devDependencies": {
    ...
    "electron": "1.7.10",
    "electron-builder": "19.54.0",
    "electron-publisher-s3": "^19.55.2"
  },
  "dependencies": {
    ...
    "electron-log": "2.2.14",
    "electron-updater": "2.20.0"
  }

electron-build.json

{
  "appId": "com.kkl.test",
  "publish": [
    {
      "provider": "s3",
      "bucket": "somebucket",
      "region": "eu-central-1"
    }
  ],
  "productName": "test",
  "directories": {
    "output": "app-builds"
  },
  "win": {
    "target": [
      "nsis-web"
    ]
  },
  "nsisWeb": {
    "differentialPackage": true,
    "oneClick": false,
    "perMachine": true,
    "allowElevation": true,
    "allowToChangeInstallationDirectory": true,
    "unicode": true,
    "runAfterFinish": true,
    "deleteAppDataOnUninstall": true
  }
}

log.log file:

[2018-01-24 21:29:57.751] [info] Found version 0.0.4-test (url: test Web Setup 0.0.4-test.exe)
[2018-01-24 21:29:57.751] [info] { info: 
   { version: '0.0.4-test',
     files: [ [Object] ],
     path: 'test Web Setup 0.0.4-test.exe',
     sha512: 'jcijdawbJlHYIm6vf43RQeMTm1QLMhjZ1J3rviGW6XRwvd/J7Q3RC6I4zihJjh97CjUe+KJ7X1H/5WVLICLlKw==',
     packages: { ia32: [Object], x64: [Object] },
     sha2: 'c9e920597c31b826e332614ac824a69dc30bd0b01586fce737fe4fe09eca4153',
     releaseDate: '2018-01-24T15:47:49.189Z' },
  type: 'update-available' }
[2018-01-24 21:29:57.753] [info] Downloading update from test Web Setup 0.0.4-test.exe
[2018-01-24 21:29:58.064] [info] { progressObj: 
   { total: 511884,
     delta: 511884,
     transferred: 511884,
     percent: 100,
     bytesPerSecond: 2337370 },
  type: 'progress' }
[2018-01-24 21:29:58.709] [info] File has 10350 changed blocks
[2018-01-24 21:29:58.713] [info] Full: 246,918.68 KB, To download: 211,158.25 KB (86%)
[2018-01-24 21:29:58.718] [info] Differential download: https://bucket.s3.amazonaws.com/somefile-0.0.4-test-x64.nsis.7z

Is there a way to use differentialPackage and nicely show download progress of all files? Or maybe there is something wrong in my setup ?

@develar any updates on that ? Is it desired behaviour that it only shows download-progress messages for installer file or maybe my setup is wrong?

Differential downloader doesn't emit progress events. This feature is not yet implemented, and no plans for this month (a lot of other more important issues).

19.54.0
To download: 211,158.25 KB (86%)

Are both versions were build using electron-builder 19.54.0?

@develar that feature would be great to show full progress but still good to know what is currently possible so thanks for you answer

(yes, both 19.54.0)

(yes, both 19.54.0)

Do you happy to see 211,158.25 KB (86%) Is there any explanation why (did you change a lot of code or assets)?

@develar yes, including external app in the package

@develar another idea: could it be handled this way: user only needs to download web installer file and the rest is downloaded in the installer, maybe this would be easier to implement. It could also be optional behaviour. Just shooting some ideas.

The only reason why it is not implemented β€” lack of time. "Download plan" is computed in advance, so, we can report progress during differential downloading.

Any update on this?

I need this feature too

We have also run into the same issue with our app. Would be great to see this feature implemented soon...
Guess I'll have to show a "spinner" until I can get progress. πŸ˜ƒ

Having a need for this feature as well as it confuses users a lot during upgrading on windows. Any quick pointers where the event is being raised on osx and where it should be added on windows? I could have a look at it and maybe fix it.

@ajochems DifferentialDownloader.ts is not aware about progress ;)

Also having this problem

electron-builder 21.2.0 not work

up

the event is not working in 21.2.0

Since the callback is not implemented yet, can we disable differential downloads instead? I noticed that differential downloads are only used on Linux, on Windows the download-progress callback is working.

@sscullen it's not working on windows, are you sure?

@Romain-P On windows the 'download-progress' callback is called. On Linux it isn't. I'm not sure how to check the console.log of the main.js electron process on windows, but I have a progress bar that initiates from the download-progress callback, it works on Windows, it doesn't work on Linux. I changed the progress bar to be indefinite if I'm running on Linux, that's the temporary solution I'm going with for now.

In "differential download" case, 'download-progress' doesn't emit on windows 10.

dig commented

Also getting the same issue, download-progress never fires. Any ETA on a fix?

Same problem, event download-progress is not triggered when making windows update "electron-builder": "^21.1.4"

I had this problem too, as a workaround i made this
Based on messages which are logged in console by updater im calculating percentage and speed

I had this problem too, as a workaround i made this
Based on messages which are logged in console by updater im calculating percentage and speed

Thank you so much!

I had this problem too, as a workaround i made this
Based on messages which are logged in console by updater im calculating percentage and speed

Thank you so much! it's work!
But still need:autoUpdater.on('download-progress'...

This is full code:

const { autoUpdater } = require("electron-updater")
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
let diffDown = {
percent: 0,
bytesPerSecond: 0,
total: 0,
transferred: 0
};
let diffDownHelper = {
startTime: 0,
lastTime: 0,
lastSize: 0
};

log.hooks.push((msg, transport) => {
if (transport !== log.transports.console) {
return msg;
}

let match = /Full: ([\d,.]+) ([GMKB]+), To download: ([\d,.]+) ([GMKB]+)/.exec(
msg.data[0]
);
if (match) {
let multiplier = 1;
if (match[4] == 'KB') multiplier *= 1024;
if (match[4] == 'MB') multiplier *= 1024 * 1024;
if (match[4] == 'GB') multiplier *= 1024 * 1024 * 1024;

diffDown = {
  percent: 0,
  bytesPerSecond: 0,
  total: Number(match[3].split(',').join('')) * multiplier,
  transferred: 0
};
diffDownHelper = {
  startTime: Date.now(),
  lastTime: Date.now(),
  lastSize: 0
};
return msg;

}

match = /download range: bytes=(\d+)-(\d+)/.exec(msg.data[0]);
if (match) {
const currentSize = Number(match[2]) - Number(match[1]);
const currentTime = Date.now();
const deltaTime = currentTime - diffDownHelper.startTime;

diffDown.transferred += diffDownHelper.lastSize;
diffDown.bytesPerSecond = Math.floor(
  (diffDown.transferred * 1000) / deltaTime
);
diffDown.percent = (diffDown.transferred * 100) / diffDown.total;

diffDownHelper.lastSize = currentSize;
diffDownHelper.lastTime = currentTime;

mainWindow.webContents.send('download_progress', diffDown);
return msg;
}
return msg;
});

autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
// sendStatusToWindow('downloading', log_message);
log.info(log_message);
if (mainWindow) {
mainWindow.webContents.send('download_progress', progressObj.percent);
}
})

Any update on this?
I have also run into the same issue on window7

Its 2020 and still this feature isnt implemented yet :(

At the moment it appears there are a few work-arounds suggested above, although if these do not suffice for now, you could always help develar prioritize this ticket by supporting the project via the Sponsor page, to help him raise priority on the issue (it's a great cause, and the project contributors only have so much time in a day; You should check out develar's Contribution activity on his profile page, there's hardly a day that goes by that he isn't committing to at least several repositories.)

https://www.electron.build/donate

I've also got the same issue

Thanks !! Are you going to merge that project into the electron-updater?? @harshitsilly

Thanks !! Are you going to merge that project into the electron-updater?? @harshitsilly

@chesucr right now we have features like the differential update for mac(zip) , have app updater cache location to user app support location + this one.
I highly doubt if we raise pr for all these features then it will get merged.. what we want to have is the electron-updater enabled with these functionalities ...we will try to close bugs or have features that electron builder community does not takes.. Maybe in the future, if things work well then there is a chance of pr
or for particular this fix we can have the pr but for that, we have to adhere to the electron-builder guidelines which can take time.

@soubhikchatterjee @aultuser @the3moon @chesucr - Hi, try this module electron-differential-updater.. it is built on top of electron-builder and help u with the fix. We are done with the documentation
It also has differential update for mac also.