Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 16的makeKeyWindow导致页面的Size发生不必要的变化 #573

Closed
hstdt opened this issue Sep 16, 2022 · 5 comments
Closed

iOS 16的makeKeyWindow导致页面的Size发生不必要的变化 #573

hstdt opened this issue Sep 16, 2022 · 5 comments
Labels

Comments

@hstdt
Copy link

hstdt commented Sep 16, 2022

继续 #532 的讨论

必现/偶发?
项目必现,demo一定概率触发

描述bug
LandscapePortrait的时候,必然会导致一次sourceWindow的size发生变化,而实际上此时rootViewController并不会发生转动,还是被触发了viewWillTransition,{414, 896} -> {896, 414} -> {414, 896}
这些逻辑在demo中无法很好体现,但是在实际项目中,会导致页面不必要的滑动,Player停止(注释掉所有的viewWillTransition方法也照旧)

Demo中是否存在同样的问题?

你期望的结果是什么?
不要触发viewWillTransition等其他操作

运行环境

  • iPhone X
  • iOS 16
  • Xcode 14
  • Swift

截图
makeKeyWindow之前的frame是正确的,在调用之后尺寸反而发生了变化

CleanShot 2022-09-16 at 20 55 18

尝试采用的一些workaround:

  1. rootViewController暂时拿掉,不起作用,window尺寸没变化了,但是viewWillTransition还是会被触发

CleanShot 2022-09-16 at 20 54 24

  1. SJRotationFullscreenWindowalpha设置为0从而隐藏,效果较好。就算很复杂的项目,只要不触发旋转,就会减少很多意外
    changsanjiang/SJBaseVideoPlayer@master...hstdt:SJBaseVideoPlayer:master

CleanShot 2022-09-16 at 21 07 22

额外的

#532 中的demo差距不大,就是增加了一个打印,展示window尺寸莫名发生了变化
player.zip

@hstdt hstdt added the bug label Sep 16, 2022
@hstdt
Copy link
Author

hstdt commented Sep 17, 2022

@changsanjiang 加了一个ParentViewController之后,出现位移的概率大幅增加(这也是我项目目前的用法,再参杂其他逻辑,以及更多childviewcontroller,导致几乎复现率100%)

2022-09-17.10.43.19.mp4

playerv3.zip

update: 小乌龙
此demo没有成功加上container,只是改变了cell高度,就触发了

update 2:
ParentViewController + cell高度很高,触发率大幅提升

2022-09-17.11.06.47.mp4

playerv3.1.zip

@lunarboat
Copy link

同问,出现相同问题,在横屏旋转恢复到竖屏列表时候,contentOffset会变化

@hstdt
Copy link
Author

hstdt commented Sep 23, 2022

补充一个发现,application(_:supportedInterfaceOrientationsFor:) 如果固定返回.portrait,那么还是能旋转,且不会触发viewWillTransition,感觉可以在这个方法里面优化逻辑。比如结合isHiddenisKeywindow这两个属性。

changsanjiang added a commit that referenced this issue Oct 17, 2022
@changsanjiang
Copy link
Owner

已修复, SJBaseVideoPlayer 需要更新到 3.7.5;

@changsanjiang
Copy link
Owner

@lunarboat @hstdt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants