Git Product home page Git Product logo

Comments (5)

yulingtianxia avatar yulingtianxia commented on May 28, 2024

@ZhangTonghai 没太看懂 crash 的原因,是 EditViewController_8_XXXX 这个类已经不存在了么?麻烦能提供个能复现的 demo 么?

from messagethrottle.

ZhangTonghai avatar ZhangTonghai commented on May 28, 2024

手误关闭了issue,叹气!!

from messagethrottle.

ZhangTonghai avatar ZhangTonghai commented on May 28, 2024

Demo

复现步骤:
1、运行后点击第一个页面红色cell,进入第二个vc
2、返回第一个vc并重复步骤1
3、重复步骤2 ,出现崩溃,如下图
azF3YEtRXUTcgLC

神策业务的大致流程是这样的:

- (void)sensorsdata_setDelegate:(id <UICollectionViewDelegate>)delegate(UIScrollView+AutoTrack.m)

+ (void)hookDidSelectMethodWithDelegate:(id)delegate(SADelegateProxy.m)

+ (NSString *)generateSensorsClassName:(id)obj(SADelegateProxy.m)

...

希望提供的资料有用。

from messagethrottle.

ZhangTonghai avatar ZhangTonghai commented on May 28, 2024

补充:
在设置collectionView的delegate之前调用mt_limitSelector则不会有问题,所以我还没断定问题在这边还是神策方面,忘指点。

from messagethrottle.

yulingtianxia avatar yulingtianxia commented on May 28, 2024

Crash 原因是 MessageThrottle 这边直接使用了神策动态创建的子类,然后下次神策创建新的子类时,会销毁旧创建的子类,导致下次 MessageThrottle 访问到不存在的类而 crash。神策使用 objc_disposeClassPair() 函数销毁创建的类时,一旦这个类存在实例,或存在其子类的实例,那么就会发生问题。因为神策在销毁子类之前并没有按照苹果官网文档的要求进行检查(是否存在实例或子类),而是暴力销毁,所以发生在神策之后的 Hook 操作都会受此影响,此问题需要神策来修复:

/** 
 * 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 了。其实神策反复创建有计数功能的子类并逐个销毁的做法有一定风险,如果换成用属性等来计数可能会更好。

from messagethrottle.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.