<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>497571</bug_id>
          
          <creation_ts>2024-12-16 19:33:46 +0000</creation_ts>
          <short_desc>Window recording gives incorrect resolution with display scaling, in both spectacle and obs-studio</short_desc>
          <delta_ts>2024-12-17 15:40:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>kwin</product>
          <component>screencasting</component>
          <version>6.2.4</version>
          <rep_platform>NixOS</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Oxalica">oxalicc</reporter>
          <assigned_to name="KWin default assignee">kwin-bugs-null</assigned_to>
          <cc>nate</cc>
    
    <cc>oxalicc</cc>
    
    <cc>xaver.hugl</cc>
          
          <cf_commitlink>https://invent.kde.org/plasma/kwin/-/commit/4048d208f72b74f2393e6f129a1802ae447f228b</cf_commitlink>
          <cf_versionfixedin>6.2.5</cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2381927</commentid>
    <comment_count>0</comment_count>
    <who name="Oxalica">oxalicc</who>
    <bug_when>2024-12-16 19:33:46 +0000</bug_when>
    <thetext>SUMMARY

Window recording produces a video with resolution of actual resolution divided by scaling factor (logical geometry?), rather than actual resolution, resulting a blurry and small content. While full screen recording produces correct actual physical resolution.

It is also reproducible in obs-studio (https://github.com/obsproject/obs-studio) via &quot;Screen Capture (Pipewire)&quot;: with the same full screen game, capturing the full screen gives a 2560x1440 clear source, while capturing the game window itself gives a 2048x1152 blurry source. (My display is 2560x1440 with 125% scale)

STEPS TO REPRODUCE

1. Have a 2560x1440 display, and set scale to 125%
2. Open &quot;dolphin&quot; and maximize it to occupy (almost) the full screen.
3. Open &quot;spectacle&quot;, click &quot;Recording&quot; - &quot;Window&quot; - select the dolphin window. Wait for one second and stop recording.
4. Repeat 3 but record with &quot;Full Screen&quot;.

OBSERVED RESULT

The video from step 3 (window recording) is 2048x1104 for me, which is approximately (2560/1.25)x(1440/1.25), minus the plasma panel on the top. The text in video is also blurry and hard to read.
The video from step 4 (full screen recording) is exactly 2560x1440, the text inside is clear and easy to read.

EXPECTED RESULT

The resolution of video from step 3 should be 2560x(1440 - top panel height) on maximized dolphin window. And the text should be as clear as in full screen recorded video.

SOFTWARE/OS VERSIONS

Operating System: NixOS 25.05
KDE Plasma Version: 6.2.4
KDE Frameworks Version: 6.8.0
Qt Version: 6.8.0
Kernel Version: 6.6.63 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5700G with Radeon Graphics
Memory: 31.0 GiB of RAM
Graphics Processor: Mesa Intel® Arc

ADDITIONAL INFORMATION

Also reproduced in obs-studio 30.2.3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2381977</commentid>
    <comment_count>1</comment_count>
    <who name="Oxalica">oxalicc</who>
    <bug_when>2024-12-16 21:11:46 +0000</bug_when>
    <thetext>After some debugging, I made it work with the following patch on top of kwin v6.2.4. With it, both spectacle and obs-studio record the non-scaled correct resolution and the content looks clear. I hope it helps, but I&apos;m not sure if it&apos;s ideal and it&apos;s not applicable on kwin master due to some non-trivial code change.

```
diff --git a/src/plugins/screencast/windowscreencastsource.cpp b/src/plugins/screencast/windowscreencastsource.cpp
index f2a1432e4d..2b2c6ed36d 100644
--- a/src/plugins/screencast/windowscreencastsource.cpp
+++ b/src/plugins/screencast/windowscreencastsource.cpp
@@ -49,12 +49,12 @@ quint32 WindowScreenCastSource::drmFormat() const
 
 QSize WindowScreenCastSource::textureSize() const
 {
-    return m_window-&gt;clientGeometry().size().toSize();
+    return m_window-&gt;clientGeometry().size().toSize() * devicePixelRatio();
 }
 
 qreal WindowScreenCastSource::devicePixelRatio() const
 {
-    return 1.0;
+    return m_window-&gt;preferredBufferScale();
 }
 
 void WindowScreenCastSource::render(QImage *target)
-- 
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2382002</commentid>
    <comment_count>2</comment_count>
    <who name="Zamundaaa">xaver.hugl</who>
    <bug_when>2024-12-16 22:07:43 +0000</bug_when>
    <thetext>You can make that work on git master by replacing preferredBufferScale() with targetScale(). Would you like to make a merge request with that change?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2382023</commentid>
    <comment_count>3</comment_count>
    <who name="Oxalica">oxalicc</who>
    <bug_when>2024-12-16 23:51:01 +0000</bug_when>
    <thetext>(In reply to Zamundaaa from comment #2)
&gt; You can make that work on git master by replacing preferredBufferScale()
&gt; with targetScale(). Would you like to make a merge request with that change?

Thanks for the advice, but I don&apos;t have a kwin dev&amp;test environment. I&apos;m currently hot-patching kwin&apos;s Nix package in my production system. The master branch contains many dependency changes (kdecoration3 and all its dependents) which are incompatible with build scripts from released version. I&apos;m unfamiliar with fixing it.

If it&apos;s more convenient for you to test the 2-line-change, feel free to adopt it in upstream. Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2382025</commentid>
    <comment_count>4</comment_count>
    <who name="Bug Janitor Service">bug-janitor</who>
    <bug_when>2024-12-17 00:14:05 +0000</bug_when>
    <thetext>A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/6906</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2382140</commentid>
    <comment_count>5</comment_count>
    <who name="Zamundaaa">xaver.hugl</who>
    <bug_when>2024-12-17 14:11:03 +0000</bug_when>
    <thetext>Git commit b6e6000d9729f740f9a17cf4d4517703a8da09fa by Xaver Hugl.
Committed on 17/12/2024 at 13:29.
Pushed by zamundaaa into branch &apos;master&apos;.

plugins/screencast: take scaling into account for window sources

Otherwise the textures will be too small, and the result blurry

M  +2    -2    src/plugins/screencast/windowscreencastsource.cpp

https://invent.kde.org/plasma/kwin/-/commit/b6e6000d9729f740f9a17cf4d4517703a8da09fa</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2382155</commentid>
    <comment_count>6</comment_count>
    <who name="Zamundaaa">xaver.hugl</who>
    <bug_when>2024-12-17 15:18:56 +0000</bug_when>
    <thetext>Git commit 4048d208f72b74f2393e6f129a1802ae447f228b by Xaver Hugl.
Committed on 17/12/2024 at 15:18.
Pushed by zamundaaa into branch &apos;Plasma/6.2&apos;.

plugins/screencast: take scaling into account for window sources

Otherwise the textures will be too small, and the result blurry


(cherry picked from commit b6e6000d9729f740f9a17cf4d4517703a8da09fa)

Co-authored-by: Xaver Hugl &lt;xaver.hugl@gmail.com&gt;

M  +2    -2    src/plugins/screencast/windowscreencastsource.cpp

https://invent.kde.org/plasma/kwin/-/commit/4048d208f72b74f2393e6f129a1802ae447f228b</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>