@@ -717,10 +717,14 @@ <h1 class="app-header-title">Refresh Rate Test</h1>
717717 < td > Aspect Ratio</ td >
718718 < td id ="aspect-ratio "> Calculating...</ td >
719719 </ tr >
720- < tr >
721- < td > Screen Resolution</ td >
722- < td id ="resolution "> Calculating...</ td >
723- </ tr >
720+ < tr >
721+ < td > Reported Screen Size</ td >
722+ < td id ="resolution "> Calculating...</ td >
723+ </ tr >
724+ < tr >
725+ < td > Viewport Size</ td >
726+ < td id ="viewport "> Calculating...</ td >
727+ </ tr >
724728 < tr >
725729 < td > Scale (System)</ td >
726730 < td id ="scale "> Calculating...</ td >
@@ -873,6 +877,11 @@ <h1 class="app-header-title">Refresh Rate Test</h1>
873877 const fpsPreviewList = document . getElementById ( 'fps-preview-list' ) ;
874878 const presetRows = fpsPreviewList . querySelectorAll ( '.fps-preview-row' ) ;
875879
880+ const viewportElement = document . getElementById ( 'viewport' ) ;
881+
882+ let renderWidth = 0 ;
883+ let renderHeight = 0 ;
884+
876885 const staticPreviews = Array . from ( presetRows ) . map ( function ( row ) {
877886 const fps = parseInt ( row . getAttribute ( 'data-fps' ) , 10 ) ;
878887 const line = row . querySelector ( '.fps-preview-line' ) ;
@@ -991,67 +1000,72 @@ <h1 class="app-header-title">Refresh Rate Test</h1>
9911000 return width . toFixed ( 0 ) + ":" + height . toFixed ( 0 ) ;
9921001 }
9931002
994- function updateScreenDetails ( ) {
995- panelDpr = window . devicePixelRatio || 1 ;
996-
997- const logicalWidth = window . screen . width ;
998- const logicalHeight = window . screen . height ;
999-
1000- let width = logicalWidth * panelDpr ;
1001- let height = logicalHeight * panelDpr ;
1002-
1003- let currentOrientation = "Unknown" ;
1004- if ( screen . orientation && screen . orientation . type ) {
1005- currentOrientation = screen . orientation . type . indexOf ( "landscape" ) !== - 1
1006- ? "Landscape"
1007- : "Portrait" ;
1008- } else {
1009- currentOrientation = logicalWidth >= logicalHeight ? "Landscape" : "Portrait" ;
1010- }
1011-
1012- if ( currentOrientation === "Portrait" ) {
1013- const tmp = width ;
1014- width = height ;
1015- height = tmp ;
1016- }
1017-
1018- panelWidth = width ;
1019- panelHeight = height ;
1003+ function updateScreenDetails ( ) {
1004+ panelDpr = window . devicePixelRatio || 1 ;
10201005
1021- const ratio = width / height ;
1022- const aspectRatio = findClosestAspectRatio ( ratio , width , height ) ;
1006+ const logicalWidth = Number ( window . screen . width ) || 0 ;
1007+ const logicalHeight = Number ( window . screen . height ) || 0 ;
10231008
1024- resolutionElement . textContent = width . toFixed ( 0 ) + " x " + height . toFixed ( 0 ) + " px" ;
1025- scaleElement . textContent = ( panelDpr * 100 ) . toFixed ( 0 ) + "%" ;
1026- aspectRatioElement . textContent = aspectRatio ;
1027- orientationElement . textContent = currentOrientation ;
1009+ let reportedWidth = Math . round ( logicalWidth * panelDpr ) ;
1010+ let reportedHeight = Math . round ( logicalHeight * panelDpr ) ;
10281011
1029- const isPrimaryMonitor =
1030- window . screenX >= 0 &&
1031- window . screenY >= 0 &&
1032- screen . availWidth === screen . width ;
1012+ let currentOrientation = "Unknown" ;
1013+ if ( screen . orientation && screen . orientation . type ) {
1014+ currentOrientation = screen . orientation . type . indexOf ( "landscape" ) !== - 1
1015+ ? "Landscape"
1016+ : "Portrait" ;
1017+ } else {
1018+ currentOrientation = logicalWidth >= logicalHeight ? "Landscape" : "Portrait" ;
1019+ }
10331020
1034- if ( warningElement ) {
1035- warningElement . style . display = isPrimaryMonitor ? "none" : "block" ;
1036- }
1021+ if ( currentOrientation === "Portrait" ) {
1022+ const tmp = reportedWidth ;
1023+ reportedWidth = reportedHeight ;
1024+ reportedHeight = tmp ;
1025+ }
10371026
1038- const cDepthTotal = screen . colorDepth ;
1039- let bitsPerChannel = cDepthTotal / 3 ;
1040- bitsPerChannel = Math . round ( bitsPerChannel * 100 ) / 100 ;
1041- bitDepthElement . textContent = bitsPerChannel + "-bit (from " + cDepthTotal + " bpp)" ;
1042-
1043- let colorSpaceDetected = "Unknown" ;
1044- if ( window . matchMedia ) {
1045- if ( window . matchMedia ( "(dynamic-range: high)" ) . matches ) {
1046- colorSpaceDetected = "HDR" ;
1047- } else if ( window . matchMedia ( "(dynamic-range: standard)" ) . matches ) {
1048- colorSpaceDetected = "SDR" ;
1049- }
1027+ const viewportCssWidth = Math . round ( window . visualViewport ? window . visualViewport . width : window . innerWidth ) ;
1028+ const viewportCssHeight = Math . round ( window . visualViewport ? window . visualViewport . height : window . innerHeight ) ;
1029+
1030+ renderWidth = Math . round ( viewportCssWidth * panelDpr ) ;
1031+ renderHeight = Math . round ( viewportCssHeight * panelDpr ) ;
1032+
1033+ panelWidth = reportedWidth ;
1034+ panelHeight = reportedHeight ;
1035+
1036+ const ratioBaseWidth = reportedWidth || renderWidth || 1 ;
1037+ const ratioBaseHeight = reportedHeight || renderHeight || 1 ;
1038+ const ratio = ratioBaseWidth / ratioBaseHeight ;
1039+ const aspectRatio = findClosestAspectRatio ( ratio , ratioBaseWidth , ratioBaseHeight ) ;
1040+
1041+ resolutionElement . textContent = reportedWidth + " x " + reportedHeight + " px" ;
1042+ viewportElement . textContent = renderWidth + " x " + renderHeight + " px" ;
1043+ scaleElement . textContent = ( panelDpr * 100 ) . toFixed ( 0 ) + "%" ;
1044+ aspectRatioElement . textContent = aspectRatio ;
1045+ orientationElement . textContent = currentOrientation ;
1046+
1047+ const isPrimaryMonitor =
1048+ window . screenX >= 0 &&
1049+ window . screenY >= 0 &&
1050+ screen . availWidth === screen . width ;
1051+
1052+ const cDepthTotal = screen . colorDepth ;
1053+ let bitsPerChannel = cDepthTotal / 3 ;
1054+ bitsPerChannel = Math . round ( bitsPerChannel * 100 ) / 100 ;
1055+ bitDepthElement . textContent = bitsPerChannel + "-bit (from " + cDepthTotal + " bpp)" ;
1056+
1057+ let colorSpaceDetected = "Unknown" ;
1058+ if ( window . matchMedia ) {
1059+ if ( window . matchMedia ( "(dynamic-range: high)" ) . matches ) {
1060+ colorSpaceDetected = "HDR" ;
1061+ } else if ( window . matchMedia ( "(dynamic-range: standard)" ) . matches ) {
1062+ colorSpaceDetected = "SDR" ;
10501063 }
1051- colorSpaceElement . textContent = colorSpaceDetected ;
1052-
1053- return isPrimaryMonitor ;
10541064 }
1065+ colorSpaceElement . textContent = colorSpaceDetected ;
1066+
1067+ return isPrimaryMonitor ;
1068+ }
10551069
10561070 function updateGhostExpectations ( refreshRate ) {
10571071 if ( ! refreshRate || ! isFinite ( refreshRate ) || refreshRate <= 0 ) return ;
@@ -1292,16 +1306,19 @@ <h1 class="app-header-title">Refresh Rate Test</h1>
12921306 if ( timestamp - lastUpdate >= updateInterval ) {
12931307 refreshRateElement . textContent = refreshRate . toFixed ( decimals ) + ' Hz' ;
12941308
1295- const dpr = panelDpr || window . devicePixelRatio || 1 ;
1296- let width = panelWidth ;
1297- let height = panelHeight ;
1298- if ( ! width || ! height ) {
1299- width = screen . width * dpr ;
1300- height = screen . height * dpr ;
1301- }
1302-
1303- const pixelsPerFrame = width * height ;
1304- const pixelsPerSecond = pixelsPerFrame * refreshRate ;
1309+ const dpr = panelDpr || window . devicePixelRatio || 1 ;
1310+ let width = renderWidth ;
1311+ let height = renderHeight ;
1312+
1313+ if ( ! width || ! height ) {
1314+ const fallbackViewportWidth = Math . round ( ( window . visualViewport ? window . visualViewport . width : window . innerWidth ) * dpr ) ;
1315+ const fallbackViewportHeight = Math . round ( ( window . visualViewport ? window . visualViewport . height : window . innerHeight ) * dpr ) ;
1316+ width = fallbackViewportWidth ;
1317+ height = fallbackViewportHeight ;
1318+ }
1319+
1320+ const pixelsPerFrame = width * height ;
1321+ const pixelsPerSecond = pixelsPerFrame * refreshRate ;
13051322
13061323 pixelsPerFrameElement . textContent = pixelsPerFrame . toLocaleString ( ) + ' px' ;
13071324 pixelsPerSecondElement . textContent = Math . round ( pixelsPerSecond ) . toLocaleString ( ) + ' px/s' ;
0 commit comments