h***@tupai.tech
h***@tupai.tech
  • 发布:2026-04-19 22:02
  • 更新:2026-04-19 22:02
  • 阅读:30

【报Bug】iOS 26.4 横屏应用 rpx 基准宽度冻结在竖屏值

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: mac os 15.4.1

HBuilderX类型: 正式

HBuilderX版本号: 4.87

手机系统: iOS

手机系统版本号: iOS 26

手机厂商: 苹果

手机机型: 17 pro max

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

App下载地址或H5⽹址: 暂无,预发布阶段,可以联系我加入testFilght

示例代码:
  <view  
    :id="probeId"  
    :style="{  
      width: `100rpx`,  
      height: '1px',  
      position: 'fixed',  
      left: '-9999px',  
      top: '0',  
      visibility: 'hidden',  
      pointerEvents: 'none',  
    }"  
  />  
const sysInfo = uni.getSystemInfoSync()  

// uni-app rpx 计算规则 (dynamicRpx = true):  
// - windowWidth ≤ 960px: rpx = (当前屏幕宽度 / 750) × 设计值  
// - windowWidth > 960px: rpx = (375 / 750) × 设计值 (固定基准)  
const LARGE_SCREEN_THRESHOLD = 960  
const isLargeScreen = sysInfo.windowWidth > LARGE_SCREEN_THRESHOLD  

const baseWidth = isLargeScreen ? 375 : sysInfo.windowWidth  

// 期望宽度 = baseWidth × (probeRpx / 750)  
const expectedWidth = baseWidth * (probeRpx / 750)  
const rectWidth = rect.width  // boundingClientRect 返回的实际渲染宽度  
const diff = Math.abs(rectWidth - expectedWidth)  

// 反推 rpx 引擎实际使用的基准宽度  
const inferredBaseWidth = rectWidth / (probeRpx / 750)  

console.log('[LayoutGuard] check', {  
  rectWidth,  
  expectedWidth,  
  baseWidth,  
  windowWidth: sysInfo.windowWidth,  
  isLargeScreen,  
  diff,  
  platform: sysInfo.platform,  
  inferredBaseWidth,  
})  

操作步骤:
  1. 准备设备:iPhone 17 Pro Max,系统版本 iOS 26.4
  2. 完全关闭 App(从后台杀掉进程)
  3. 横或竖屏握持设备,冷启动 App
  4. 观察页面布局

预期结果:

rpx 引擎使用横屏窗口宽度(874px)作为基准:

100rpx = 874 × (100 / 750) = 116.53px

页面元素按横屏比例正常显示。

实际结果:

实际结果

rpx 引擎使用竖屏宽度(≈402px)作为基准:

100rpx = 402 × (100 / 750) = 53.59px

页面元素整体缩小约 54%(53.59 / 116.53)。

调试日志如下:

{  
  "rectWidth": 53.59375,  
  "expectedWidth": 116.53333333333333,  
  "baseWidth": 874,  
  "windowWidth": 874,  
  "isLargeScreen": false,  
  "diff": 62.93958333333333,  
  "platform": "ios",  
  "inferredBaseWidth": 401.953125  
}

bug描述:

*Bug 描述

uni-app Vue3 横屏应用在 iOS 26.4 设备(iPhone 17 Pro Max)上冷启动时,rpx 引擎的基准宽度被错误地锁定在竖屏的短边宽度(≈402px),而非横屏的长边宽度(≈874px)。

开启 dynamicRpx: true 后,uni.getSystemInfoSync().windowWidth 能正确返回横屏宽度,但 rpx 渲染引擎内部的基准值未同步更新,导致所有 rpx 单位的元素按竖屏比例渲染,页面元素整体偏小。

调用 uni.reLaunch() 重载页面后,rpx 基准仍不会更新

安卓也有类似情况,但是可以通过 uni.reLaunch 重载页面可解决该问题,ios 26.3 之前的ios 系统也不存在这个问题

相关配置

// pages.json  
{  
  "globalStyle": {  
    "pageOrientation": "landscape",  
    "screenOrientation": "landscape",  
    "navigationStyle": "custom",  
    "dynamicRpx": true  
  }  
}

预期结果

rpx 引擎使用横屏窗口宽度(874px)作为基准:

100rpx = 874 × (100 / 750) = 116.53px

页面元素按横屏比例正常显示。

实际结果

rpx 引擎使用竖屏宽度(≈402px)作为基准:

100rpx = 402 × (100 / 750) = 53.59px

页面元素整体缩小约 54%(53.59 / 116.53)。

调试日志如下:

{  
  "rectWidth": 53.59375,  
  "expectedWidth": 116.53333333333333,  
  "baseWidth": 874,  
  "windowWidth": 874,  
  "isLargeScreen": false,  
  "diff": 62.93958333333333,  
  "platform": "ios",  
  "inferredBaseWidth": 401.953125  
}

关键矛盾windowWidth 已正确返回横屏值 874,但 rpx 渲染引擎内部的基准仍为 ≈402(竖屏短边减去安全区域)。uni.reLaunch() 页面重载后基准不变,说明这是引擎层面的冻结,非页面级问题。

环境信息

项目
设备 iPhone 17 Pro Max
系统 iOS 26.4
逻辑分辨率 440pt × 956pt(@3x)
框架 uni-app Vue3
dynamicRpx true
2026-04-19 22:02 负责人:无 分享
已邀请:

要回复问题请先登录注册