Skip to content

Commit 167bd2d

Browse files
committed
Fix the issue where getWindowInfo does not have a cache, which causes lag.
1 parent f83892d commit 167bd2d

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pal/minigame/wechat_mini_program.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ minigame.createInnerAudioContext = createInnerAudioContextPolyfill(wx, {
124124
onSeek: false,
125125
}, true);
126126

127+
let _cachedSystemInfo: SystemInfo = wx.getWindowInfo();
128+
minigame.onWindowResize?.((): void => {
129+
// update cached system info
130+
_cachedSystemInfo = wx.getWindowInfo() as SystemInfo;
131+
});
132+
minigame.getWindowInfo = (): SystemInfo => _cachedSystemInfo;
133+
127134
// #region SafeArea
128135
// FIX_ME: wrong safe area when orientation is landscape left
129136
minigame.getSafeArea = (): SafeArea => {

0 commit comments

Comments
 (0)