-
Notifications
You must be signed in to change notification settings - Fork 66
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
MTEngine.defaultEngine.classHooked 只有add,没有remove操作,和神策集成发生崩溃 #16
Comments
@ZhangTonghai 没太看懂 crash 的原因,是 |
手误关闭了issue,叹气!! |
补充: |
Crash 原因是 MessageThrottle 这边直接使用了神策动态创建的子类,然后下次神策创建新的子类时,会销毁旧创建的子类,导致下次 MessageThrottle 访问到不存在的类而 crash。神策使用 /**
* Destroy a class and its associated metaclass.
*
* @param cls The class to be destroyed. It must have been allocated with
* \c objc_allocateClassPair
*
* @warning Do not call if instances of this class or a subclass exist.
*/
OBJC_EXPORT void
objc_disposeClassPair(Class _Nonnull cls)
OBJC_AVAILABLE(10.5, 2.0, 9.0, 1.0, 2.0); 『在设置collectionView的delegate之前调用mt_limitSelector则不会有问题』,是因为 MessageThrottle 先创建了子类并持有,神策后创建的子类并销毁,这样就影响不到 MessageThrottle 了。其实神策反复创建有计数功能的子类并逐个销毁的做法有一定风险,如果换成用属性等来计数可能会更好。 |
我的工程中集成了神策统计,神策在处理统一的点击事件捕获是,使用了和MessageThrottle类似的生成一个形如EditViewController_6_XXXX 虚拟子类的操作,此处的数字会递增,反复进入同一个页面,可能会生成EditViewController_8_XXXX、EditViewController_9_XXXX 这种情况。
在 mt_overrideMethod 这个方法中,[MTEngine.defaultEngine.classHooked addObject:cls]添加的cls实际是神策统计生成的虚拟子类。
由于没有remove的操作,当下一次限流方法再次执行时,下面的代码在进行isSubclassOfClass判断是会发生崩溃,因为classHooked里的存放是EditViewController_8_XXXX,而传入的是EditViewController_9_XXXX。
The text was updated successfully, but these errors were encountered: