Jump to:

Problem/Motivation

Progress of Import translations automatically during installation goes to warp speed at the end after 60%
It's confusing that there is a percent on the left, and a different percent on the right, and that the task appears to finish with the progress bar partially done.

Proposed resolution

Remove the "administrative" batch steps and only keep the "core" processing steps. The core process is checking status, downloading and importing.

I'll give some background on what happens in the bath in an attempt to explain the progress bar behaviour. It may, or may not be possible to eliminate the behaviour completely.

The progress bar displays the progress of batch steps used to download and import a translation file. This batch process contains of 4 steps:

Step 1: Prepare

Step 2: Download

Step 3: Import

Step 4: Clean up and calculate results

Step 5: Save results

Drupal's batch process feedback reserves an equal amount of space for each batch step. With 4 steps, the progress bar moves 20% during each step. After step 3 the percentage indicator on the right of the bar is at 60%. But steps 1, 4 and 5 take very little time and step 3 takes a lot of time. In the case of the installer, Step 2 is skipped because the translation file was downloaded before. After spending 10 seconds initialising, 0.01 seconds step 1 and 2, 60 seconds on step 3. Now the remaining two steps only take 0.01 seconds, but after the slow import they feel like 0.00000000000000001 second.

That said, what can we do about it. Step 1 can not be removed, it is required for step 2 and 3 to do the work. Step 2 could be removed by defining a new batch the installation process only. But eliminating step 4 and 5 is a lot more work and may result in more complex code. For this to happen, steps 4 and 5 must be included in batch step 3. Only this will give the desired visual effect. This should be postponed for or combined with #1842380: Convert $source object to a TranslatableProject class. This issue will be a rewrite of the download/import code. Making the change before this issue will be a waste of effort.
An other approach to better visual presentation of the progress is to add an option in which each batch step can give an estimated amount of time compared to the total execution time.

Yeah, I admit the only thing that immediately pops to mind is something hacky like a sleep() or introducing some more bogus steps just to space it out a bit more. Maybe we'll see if anyone else complains about it before we act. I'm comfortable with a "minor" priority on this.

Ideally batch API would allow us to put in estimated percentages to each step, so it would divide the overall progress based on that. I don't think this is of immediate importance. Also batch API might have an existing issue for this.