[PR #695] [MERGED] Fix: safari bug downloadspeed #5511

Closed
opened 2026-05-28 23:37:47 +03:00 by zhus · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/sigoden/dufs/pull/695
Author: @florinm03
Created: 4/26/2026
Status: Merged
Merged: 4/27/2026
Merged by: @sigoden

Base: mainHead: fix/safari-bug-downloadspeed


📝 Commits (2)

  • 80ae2a0 NaN or undefined guard for safari and throttled DOM updates
  • 1b2a3ad use variable

📊 Changes

1 file changed (+3 additions, -1 deletions)

View changed files

📝 assets/index.js (+3 -1)

📄 Description

On Safari, the download speed was updating too fast. Moreover, the speed was not readable, and you could see NaN and undefined.

Some pictures before the fix
Screenshot 2026-04-26 at 12 52 23 Screenshot 2026-04-26 at 11 52 39 Screenshot 2026-04-26 at 11 48 35

Same upload on Brave:
Screenshot 2026-04-26 at 11 56 48


From what I gathered:

  • Safari fires progress events very rapidly
  • Two events fire within the same millisecond
  • Date.now() returns the same value for both, because of 1ms resolution
  • elapsed = 0 -> division by zero -> Infinity -> NaN cascade

Brave/Chrome have sub-millisecond timer resolution, so two events within the same millisecond still return different Date.now() values, and elapsed is never 0.

Here is a video of how it looked after the guard.

https://github.com/user-attachments/assets/182f782f-c52c-4f10-8803-b5620edd9a76

So a "throttle" was necessary, hence the elapsed < 300

https://github.com/user-attachments/assets/487a01c0-0f42-4de0-a51a-a8e84c8f60d1


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/sigoden/dufs/pull/695 **Author:** [@florinm03](https://github.com/florinm03) **Created:** 4/26/2026 **Status:** ✅ Merged **Merged:** 4/27/2026 **Merged by:** [@sigoden](https://github.com/sigoden) **Base:** `main` ← **Head:** `fix/safari-bug-downloadspeed` --- ### 📝 Commits (2) - [`80ae2a0`](https://github.com/sigoden/dufs/commit/80ae2a08f460bdbb356503608e7d929242447e81) NaN or undefined guard for safari and throttled DOM updates - [`1b2a3ad`](https://github.com/sigoden/dufs/commit/1b2a3ad742d064c8e00049033b35f24ad2c64c96) use variable ### 📊 Changes **1 file changed** (+3 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `assets/index.js` (+3 -1) </details> ### 📄 Description On **Safari**, the download speed was updating too fast. Moreover, the speed was not readable, and you could see `NaN and undefined`. <details> <summary>Some pictures before the fix</summary> <br> <img width="637" height="205" alt="Screenshot 2026-04-26 at 12 52 23" src="https://github.com/user-attachments/assets/0f5ad935-e523-4102-8eef-de99a0a67c29" /> <img width="518" height="994" alt="Screenshot 2026-04-26 at 11 52 39" src="https://github.com/user-attachments/assets/69e2d06b-7e08-47ef-a524-0fcb7c0c1c2b" /> <img width="521" height="1017" alt="Screenshot 2026-04-26 at 11 48 35" src="https://github.com/user-attachments/assets/4f435101-418d-4e89-81c5-342d3f7e1ea9" /> Same upload on Brave: <img width="669" height="950" alt="Screenshot 2026-04-26 at 11 56 48" src="https://github.com/user-attachments/assets/87b40a69-e439-4316-b963-e56cb84f1c5b" /> </details> *** **From what I gathered:** - Safari fires `progress` events very rapidly - Two events fire within the same millisecond - `Date.now()` returns the same value for both, because of 1ms resolution - `elapsed = 0` -> division by zero -> Infinity -> NaN cascade Brave/Chrome have sub-millisecond timer resolution, so two events within the same millisecond still return different `Date.now()` values, and `elapsed` is never `0`. Here is a video of how it looked after the guard. https://github.com/user-attachments/assets/182f782f-c52c-4f10-8803-b5620edd9a76 So a "throttle" was necessary, hence the `elapsed < 300` https://github.com/user-attachments/assets/487a01c0-0f42-4de0-a51a-a8e84c8f60d1 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
zhus added the pull-request label 2026-05-28 23:37:47 +03:00
zhus closed this issue 2026-05-28 23:37:47 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sigoden/dufs#5511