desktop icon indicating copy to clipboard operation
desktop copied to clipboard

[Bug]: Video playback stutters and drops frames on Windows due to widget.windows.mica DWM composition

Open eneskasikci opened this issue 2 months ago • 11 comments

Preliminary Checks

  • [x] I have read and understood the important section above.
  • [x] I have searched existing issues and avoided creating duplicates.
  • [x] I am not filing an enhancement request.
  • [x] I have checked that this issue cannot be reproduced on Mozilla Firefox.
  • [x] I have checked that this issue can be reproduced once I removed all my Mods and Custom CSS.

What happened?

TikTok (and other MSE web video players) frequently stutter, freeze, and drop frames on Windows.

  • In vanilla Mozilla Firefox: 0 dropped frames out of 2948 total frames on the exact same video.
  • In Zen Browser with widget.windows.mica = true: 28 to 67 dropped frames (4.6% to 13.5% frame loss).
  • When disabling HEVC (media.hevc.enabled = false): dropped frames drop to 0.00% (falling back smoothly to H.264).
  • When disabling Mica (widget.windows.mica = false): dropped frames drop by ~98% down to 1 out of 921 (0.11% loss).

Recommended Solution

Set media.hevc.enabled = false for Windows in prefs/zen/media.yaml:

  • Why: This achieves 0.00% dropped frames on TikTok and web media players without sacrificing Zen's signature Windows 11 Mica aesthetics.
  • Alternatively/additionally, Zen could provide an opt-in toggle under Settings -> Performance to disable Mica transparency for users experiencing DWM compositing lag.

Expected behavior

Smooth video playback matching upstream Firefox with no DWM frame drops or stuttering.

Actual behavior

Videos stutter and drop frames continuously due to Mica blur compositing overhead.

Steps to reproduce

  1. Open Zen Browser on Windows (with default widget.windows.mica = true).
  2. Play any video on TikTok (or other MSE video players).
  3. Observe dropped frames in video.getVideoPlaybackQuality().
  4. Toggle widget.windows.mica = false in about:config and restart: dropped frames immediately drop to near zero.

Screenshots and videos

No response

Version

1.22.3b

What platform are you seeing the problem on?

Windows - x64

What component is this issue related to?

Performance

Relevant log output if applicable

// --- Vanilla Mozilla Firefox (Exact same video): ---
{
  "Is HEVC Supported": true,
  "Dropped Frames": 0,
  "Total Frames": 2948,
  "Drop Rate": "0.00%"
}

// --- Zen Browser WITH Mica enabled (widget.windows.mica = true): ---
{
  "GPU": "NVIDIA GeForce RTX 4090",
  "Video Resolution": "720x1280",
  "Total Frames": 607,
  "Dropped Frames": 28,
  "Drop Rate": "4.61%"
}

// --- Zen Browser WITHOUT Mica (widget.windows.mica = false, exact same video): ---
{
  "Total Frames": 921,
  "Dropped Frames": 1,
  "Drop Rate": "0.11%"
}

eneskasikci avatar Sep 27 '26 19:09 eneskasikci

To me personally, tiktok videos still stutter regardless of whether or not mica is enabled. Though I haven't checked with numbers yet.

mr-cheffy avatar Sep 27 '26 22:09 mr-cheffy

To me personally, tiktok videos still stutter regardless of whether or not mica is enabled. Though I haven't checked with numbers yet.

Emilio linked a source code snippet on the Buzgilla ticket, showing they set the toplevel-backdrop to 3 by default; 2 is only used for popups upstream. Zen currently has 2 for the main window as well, which is what caused the stutters on my end.

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

eneskasikci avatar Sep 27 '26 23:09 eneskasikci

Same issue on Windows 11, Zen 1.22.3b. Video/GIF playback stutter and sidebar lag were fixed by setting both widget.windows.mica = false and media.hevc.enabled = false.

I applied them together, so I can't say which one did most of the work. Running on an older GPU (R7 250).

rvyyv-n avatar Sep 28 '26 21:09 rvyyv-n

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

I think it might take a bit more adjustments to how Zen's background is built up, cause changing it to 3 does make it look rather dull / grey when sliding the transparency slider left. (not debating a base layer of 3 - mica alt could be a better idea from a perf standpoint)

Propheticus avatar Sep 28 '26 22:09 Propheticus

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

I think it might take a bit more adjustments to how Zen's background is built up, cause changing it to 3 does make it look rather dull / grey when sliding the transparency slider left. (not debating a base layer of 3 - mica alt could be a better idea from a perf standpoint)

I don't think setting it to layer 3 solves it at all. media.hevc.enabled should be false regardless of mica settings, I tried every mica level with hevc.enabled true, and it still kept stuttering. Setting it to false completely solves the issue.

eneskasikci avatar Sep 28 '26 23:09 eneskasikci

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

I think it might take a bit more adjustments to how Zen's background is built up, cause changing it to 3 does make it look rather dull / grey when sliding the transparency slider left. (not debating a base layer of 3 - mica alt could be a better idea from a perf standpoint)

I don't think setting it to layer 3 solves it at all. media.hevc.enabled should be false regardless of mica settings, I tried every mica level with hevc.enabled true, and it still kept stuttering. Setting it to false completely solves the issue.

exact same behaviour noticed. having hevc.enabled set to true with mica disabled still stuttered. setting hevc.enabled to false is what fixed it completely.

rvyyv-n avatar Sep 29 '26 06:09 rvyyv-n

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

I think it might take a bit more adjustments to how Zen's background is built up, cause changing it to 3 does make it look rather dull / grey when sliding the transparency slider left. (not debating a base layer of 3 - mica alt could be a better idea from a perf standpoint)

I don't think setting it to layer 3 solves it at all. media.hevc.enabled should be false regardless of mica settings, I tried every mica level with hevc.enabled true, and it still kept stuttering. Setting it to false completely solves the issue.

What about your earlier statement "Setting it to 3 in about:config fixed my stuttering completely."? Was this a false observation caused by other config changes?

Propheticus avatar Sep 29 '26 07:09 Propheticus

Setting it to 3 in about:config fixed my stuttering completely. Up to you whether you want to align it with upstream (3) or keep it at 2. You can let me know if you want me to open a new PR.

I think it might take a bit more adjustments to how Zen's background is built up, cause changing it to 3 does make it look rather dull / grey when sliding the transparency slider left. (not debating a base layer of 3 - mica alt could be a better idea from a perf standpoint)

I don't think setting it to layer 3 solves it at all. media.hevc.enabled should be false regardless of mica settings, I tried every mica level with hevc.enabled true, and it still kept stuttering. Setting it to false completely solves the issue.

What about your earlier statement "Setting it to 3 in about:config fixed my stuttering completely."? Was this a false observation caused by other config changes?

It might be. In that earlier quick test, TikTok's player might temporarily fell back to an H.264 chunk (or served an older, non-HEVC video in the feed), which led to that false observation.

Did an another test, restarting zen each time, opening the same or random videos on TikTok.

Test Configuration Total Frames Dropped Frames Drop Rate
Mica 2 (HEVC On) 449 103 22.94%
Mica 3 (HEVC On) 897 192 21.40%
Mica 1 (HEVC On) 450 14 3.11%
Mica 1 (HEVC False) 449 0 0.00%
Mica 2 (HEVC False) 449 0 0.00%
Mica 3 (HEVC False) 359 0 0.00%

You can also try it yourself with this piece of debugging code, Right click > Inspect > Paste it on the Console tab

(async (testName = "Mica 3 (HEVC On)") => {
  const v = document.querySelector('video');
  if (!v) return console.error("No video element found!");

  console.log(`⏱️ Benchmarking [${testName}] for 15s... please don't switch tabs.`);
  v.currentTime = 0;
  await v.play();

  const qStart = v.getVideoPlaybackQuality();
  const startFrames = qStart.totalVideoFrames;
  const startDropped = qStart.droppedVideoFrames;

  await new Promise(r => setTimeout(r, 15000));

  const qEnd = v.getVideoPlaybackQuality();
  const total = qEnd.totalVideoFrames - startFrames;
  const dropped = qEnd.droppedVideoFrames - startDropped;
  const dropRate = ((dropped / (total || 1)) * 100).toFixed(2);

  console.table([{
    "Test Configuration": testName,
    "Total Frames": total,
    "Dropped Frames": dropped,
    "Drop Rate": `${dropRate}%`
  }]);
})("Mica 3 (HEVC On)"); // <-- Change label for each run

eneskasikci avatar Sep 29 '26 08:09 eneskasikci

@eneskasikci Can you see what container TikTok uses for the video? Is this an MKV per change? https://bugzilla.mozilla.org/show_bug.cgi?id=2069252

In my testing on Linux (no Mica in sight) I can test HEVC videos that drop 40-50% of frames, but also test others that drop 0 frames even at 8k 60fps. The ones that drop frames are all in MKV.

MP4

The first video on https://lf-tk-sg.ibytedtos.com/obj/tcs-client-sg/resources/video_demo_hevc.html

Test Configuration Total Frames Dropped Frames Drop Rate
HEVC in MP4 448 0 0.00%

MKV

The video file at https://dl6.webmfiles.org/video-h265.mkv (opens in Firefox's own video player)

Test Configuration Total Frames Dropped Frames Drop Rate
HEVC in MKV 369 143 38.75%

Propheticus avatar Sep 29 '26 13:09 Propheticus

@eneskasikci Can you see what container TikTok uses for the video? Is this an MKV per change? https://bugzilla.mozilla.org/show_bug.cgi?id=2069252

In my testing on Linux (no Mica in sight) I can test HEVC videos that drop 40-50% of frames, but also test others that drop 0 frames even at 8k 60fps. The ones that drop frames are all in MKV.

MP4

The first video on https://lf-tk-sg.ibytedtos.com/obj/tcs-client-sg/resources/video_demo_hevc.html Test Configuration Total Frames Dropped Frames Drop Rate HEVC in MP4 448 0 0.00%

MKV

The video file at https://dl6.webmfiles.org/video-h265.mkv (opens in Firefox's own video player) Test Configuration Total Frames Dropped Frames Drop Rate HEVC in MKV 369 143 38.75%

They don't use MKV, it's video/mp4 (Fragmented MP4 / fMP4). As far as I can tell.

eneskasikci avatar Sep 29 '26 18:09 eneskasikci

Some data points from a setup where this does not reproduce, in case it helps narrow it down (it may be hardware/driver dependent).

Setup

  • Zen 1.24.1b, Windows 11 Pro (build 26200)
  • NVIDIA RTX 5060 Ti, driver 32.0.16.1692 (616.92), i5-14400F
  • Fresh profile, no extensions, no mods
  • HEVC Video Extensions 2.5.48.0, media.hevc.enabled = true, media.wmf.hevc.enabled = 1

Configurations

  • A: widget.windows.mica = true, widget.windows.mica.toplevel-backdrop = 2 (current Zen default)
  • B: widget.windows.mica = true, widget.windows.mica.toplevel-backdrop = 3
  • C: widget.windows.mica = false

Method: getVideoPlaybackQuality() delta over 25–40 s of playback, window ~1086×1023, 1080p Big Buck Bunny clips (H.264 and HEVC). For the MSE case the MP4 was split into fMP4 fragments with mp4box.js and fed through a SourceBuffer, similar to how TikTok-style players work.

Test A B C
H.264, plain <video src> (1–2 clean runs each, 750 frames) 0 dropped* 0 0
H.264, MSE via dash.js, 1080p (3 runs each, 1200 frames) 0 0 0
HEVC, plain <video src> (750 frames) 0 – –
HEVC, MSE fMP4 (3 runs, 901 frames) 0 – –
H.264, MSE fMP4 (901 frames) 0 – –

* The very first A run showed 59/750 dropped (7.9%), but it overlapped with another Zen instance shutting down on the same machine, and I couldn't reproduce it afterwards, so I'm treating it as noise.

GPU/main process CPU during playback was within run-to-run noise across A/B/C. Since the worst case (A + HEVC + MSE) showed no drops at all, I didn't repeat the HEVC runs for B and C.

Not tested: fullscreen/maximized window, 4K content, MKV containers.

Two side notes that might help others testing this:

  • canPlayType('video/mp4; codecs="hvc1"') returns an empty string here, while hvc1.1.6.L120.90 / hev1.1.6.L120.90 return "probably". Testing with the short string can make it look like HEVC is unsupported.
  • About backdrop 3 looking dull/grey: in src/zen/common/styles/zen-theme.css, when toplevel-backdrop is neither 1 nor 2, --zen-themed-toolbar-bg-transparent is set to rgba(255, 255, 255, 0.2) (applied to #zen-main-app-wrapper). A white overlay like that would wash out a dark theme, so it may be worth adjusting it if the default ever moves to 3.

colituvpn avatar Nov 12 '26 06:11 colituvpn