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

UIImage (QMUI) 内对 resizableImage 使用了错误的 capInsets 值进行提醒时,使用 NSAssert 不太恰当 #421

Closed
4 tasks done
Zhaoxinak opened this issue Nov 2, 2018 · 17 comments
Labels

Comments

@Zhaoxinak
Copy link

Zhaoxinak commented Nov 2, 2018

UIImage (QMUI) resizableImageWithCapInsets 传进来的 capInsets 的水平/垂直方向的和应该小于图片本身的大小,否则会导致 render 时出现 invalid context 0x0 的错误

请填写运行环境

  • 设备: iPhone SE
  • 系统:iOS 12.1
  • Xcode 版本:10.1
  • QMUI iOS 版本:2.9.0

请描述具体问题

更新后:
UIImage (QMUI) resizableImageWithCapInsets 传进来的 capInsets 的水平/垂直方向的和应该小于图片本身的大小,否则会导致 render 时出现 invalid context 0x0 的错误

相关截图(断点的堆栈、控制台的 log)

@MoLice
Copy link
Collaborator

MoLice commented Nov 2, 2018

你想说什么?

@Zhaoxinak
Copy link
Author

更新后直接崩溃。 2.8.1 无此问题。

@MoLice
Copy link
Collaborator

MoLice commented Nov 2, 2018

这是命中了不安全代码的 assert,检查你的图片的 capInsets 值是否如提示里所说的,如果是,改为合理的值即可。

@Zhaoxinak
Copy link
Author

我没有设置这个值, 图片只在QMUIButton 使用了, 上图下文字的展示方式, 更新后直接报错了。

@Zhaoxinak
Copy link
Author

Zhaoxinak commented Nov 2, 2018

查出位置了:
UISearchBar *searchBar = [[UISearchBar alloc]init];
searchBar.frame = CGRectMake(0, 8, kScreen_Width, 30); (这句报错, 搞不懂)

更了最新的QMUI 就报错,然后报以上那个问题。

@MoLice
Copy link
Collaborator

MoLice commented Nov 2, 2018

我测试了并没有重现。你是否在项目里有修改过 UISearchBar 的样式?例如通过 QMUI 配置表的方式,或者通过系统的 appearance,如果有,请贴出你修改的代码。

@ZhangTonghai
Copy link

我也遇到的同样的问题,最终查找问题是在UITabbarController的子类中有以下代码
[self.tabBar setBackgroundImage:[UIImage new]];
希望对其他人有帮助

@DarrenKong
Copy link

我测试了并没有重现。你是否在项目里有修改过 UISearchBar 的样式?例如通过 QMUI 配置表的方式,或者通过系统的 appearance,如果有,请贴出你修改的代码。

@selector(resizableImageWithCapInsets:resizingMode:)

在UIImage+QMUI中的这个方法会引起crash。QMUIDemo_iOS项目,用真机测试“保存视频到指定相册”功能,必现

@ZhangTonghai
Copy link

ZhangTonghai commented Nov 8, 2018

请填写运行环境

  • 设备:iPhone7 Plus
  • 系统:iOS 12.1
  • Xcode: 10.1
  • QMUI iOS 版本:2.9.0

请描述具体问题

又遇到了,这次是调用imageNamed:方法的时候。
截图部分分别是我是图片的信息,崩溃的堆栈、和控制台log,希望帮忙解答。

相关截图(断点的堆栈、控制台的 log)

qq20181108-152311 2x

qq20181108-152929 2x

qq20181108-153251 2x

@MoLice
Copy link
Collaborator

MoLice commented Nov 8, 2018

@ZhangTonghai 看你的最后一张截图里,当前的 top/left 分别为 291、292,请问这两个值是你显式写了 291、292 吗?

@MoLice
Copy link
Collaborator

MoLice commented Nov 8, 2018

我也遇到的同样的问题,最终查找问题是在UITabbarController的子类中有以下代码
[self.tabBar setBackgroundImage:[UIImage new]];
希望对其他人有帮助

对于 [UIImage new] 这种特殊情况,新版本已做了保护,请等待发布。

@ZhangTonghai
Copy link

请问

@ZhangTonghai 看你的最后一张截图里,当前的 top/left 分别为 291、292,请问这两个值是你显式写了 291、292 吗?

并没有,我显式写的是UIEdgeInsets insets = UIEdgeInsetsMake(20, 30, 20, 10),而且291、292分别对应了我使用的图的宽高。

@ZhangTonghai
Copy link

我测试了并没有重现。你是否在项目里有修改过 UISearchBar 的样式?例如通过 QMUI 配置表的方式,或者通过系统的 appearance,如果有,请贴出你修改的代码。

@selector(resizableImageWithCapInsets:resizingMode:)

在UIImage+QMUI中的这个方法会引起crash。QMUIDemo_iOS项目,用真机测试“保存视频到指定相册”功能,必现

我在真机上运行demo也出现了复现了这个bug。

@MoLice
Copy link
Collaborator

MoLice commented Nov 8, 2018

我测试了并没有重现。你是否在项目里有修改过 UISearchBar 的样式?例如通过 QMUI 配置表的方式,或者通过系统的 appearance,如果有,请贴出你修改的代码。

@selector(resizableImageWithCapInsets:resizingMode:)
在UIImage+QMUI中的这个方法会引起crash。QMUIDemo_iOS项目,用真机测试“保存视频到指定相册”功能,必现

我在真机上运行demo也出现了复现了这个bug。

你引用的那段文字里有两个问题,一个是 UISearchBar 的,另一个是系统视频框架的,系统的视频是会命中,我们再考虑怎么处理。UISearchBar 那个无法重现。

@MoLice MoLice changed the title 2.9.0更新后出现这个问题 UIImage (QMUI) 内对 resizableImage 使用了错误的 capInsets 值进行提醒时,使用 NSAssert 不太恰当 Nov 9, 2018
@MoLice MoLice added the suggest label Nov 9, 2018
@bluesky335
Copy link

bluesky335 commented Nov 13, 2018

同样的问题, 但是我的情况有点特殊, 我使用了融云的IMKit , 错误出现在融云的聊天气泡的背景图, 那里的代码都是融云SDK内的, 我并没有做任何修改, 旧版本没有这个问题.

@MoLice
Copy link
Collaborator

MoLice commented Nov 13, 2018

已发布 2.9.1,增加配置表开关 ShouldAssertResizableImageCapInsetsError 用于控制遇到这种情况下用 assert 还是用 log 提醒,默认用 log 提醒,可更新版本后使用。

@MoLice MoLice closed this as completed Nov 13, 2018
@MoLice
Copy link
Collaborator

MoLice commented Jan 19, 2019

3.1.0 开始,配置表开关 ShouldAssertResizableImageCapInsetsError 被废弃,这种类型的错误以后会使用 QMUILogWarn() 搭配 QMUIConsole 提示。

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

5 participants