Skip to content

Crashed when use YYWebImage and Performance #1936

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

Closed
status302 opened this issue Oct 12, 2018 · 12 comments
Closed

Crashed when use YYWebImage and Performance #1936

status302 opened this issue Oct 12, 2018 · 12 comments

Comments

@status302
Copy link

[READ] Step 1: Are you in the right place?

Yeah, I'm using in right place.

[REQUIRED] Step 2: Describe your environment

  • Xcode version: 9.4.1
  • Firebase SDK version: 5.7.0
  • Firebase Component: Performance (Auth, Core, Database, Firestore, Messaging, Storage, etc)
  • Component version: 2.1.1

[REQUIRED] Step 3: Describe the problem

Crash log is below:

 [Firebase/Analytics][I-ACS901006] Received SSL challenge for host. Host: https://app-measurement.com/a
2018-10-12 10:29:29.608096+0800 QwikMatchDev[284:58201] *** Assertion failure in -[GULObjectSwizzler swizzle], /Users/yolo/Work/code/TongZhuoGlobal/Pods/GoogleUtilities/GoogleUtilities/ISASwizzler/GULObjectSwizzler.m:146
2018-10-12 10:29:29.615624+0800 QwikMatchDev[284:58201] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The original class must be the same as the class returned by object_setClass'
*** First throw call stack:
(0x18eb92fe0 0x18d5f4538 0x18eb92eb4 0x18f62a720 0x102209cb0 0x10089aea4 0x10c6e1a10 0x10c6ee5bc 0x10089a9d8 0x10089dabc 0x107458b3c 0x18f6864cc 0x18eb4142c 0x18eb40d9c 0x18eb3e9a8 0x18ea6eda4 0x18f588d74 0x18f5dd6c4 0x107457a0c 0x18f6862d8 0x18dc5568c 0x18dc5559c 0x18dc52cb4)

Steps to reproduce:

When using YYWebImage and Performance, it will reproduce.

Relevant Code:

  • code from YYWebImage
    // this code is from YYWebImage: https://github.com/ibireme/YYWebImage/blob/093193c67bfa2409af93e618a48e3208d63106a5/YYWebImage/YYWebImageOperation.m#L375-L382
    if (![self isCancelled]) {
        _connection = [[NSURLConnection alloc] initWithRequest:_request delegate:[_YYWebImageWeakProxy proxyWithTarget:self]];
        if (![_request.URL isFileURL] && (_options & YYWebImageOptionShowNetworkActivity)) {
            [YYWebImageManager incrementNetworkActivityCount];
        }
    }
@paulb777
Copy link
Member

Thanks for the report. Tracking internally at b/117644780

@jazz-mobility
Copy link

Any updates on this. I am getting same crash on 5.9.0

@mberndt92
Copy link

mberndt92 commented Oct 19, 2018

Same crash, version is 5.9.0. Its crashing inside the class GULObjectSwizzler, lines 144-146.
screen shot 2018-10-19 at 08 58 54

@keigo-amai
Copy link

I am getting same crash on ver5.10.0 SDK.
I'm using NSURLConnection, too.

When I commented out the line [[NSURLConnection alloc] initWithRequest: delegate:].
It seems to work.

@kazuhiro4949
Copy link

kazuhiro4949 commented Oct 31, 2018

I'm getting the same assert on v5.11.0. The variables have classes initializing NSURLConnection.

@jazz-mobility
Copy link

@paulb777 Any updates on this. I figured out one thing, this crash is only happens in debug mode.

@morganchen12
Copy link
Contributor

Can one of you share a stack trace of the crash? The one in the original issue is unsymbolicated. Thanks!

@kazuhiro4949
Copy link

kazuhiro4949 commented Nov 5, 2018

@morganchen12
I figured out what's happened in my case. It seems nothing to do with NSURLConnection.
I used KVO and initialized NSURLConnection in class A.
KVO makes a subclass of class A automatically, named NSKVONotifying_A.
It doesn't match with the original class name. So the app hooks the above assert.

For example, the following view controller makes crash in debug mode.

class ViewController: UIViewController {
    @objc var urlConnection: NSURLConnection?
    override func viewDidLoad() {
        super.viewDidLoad()
        addObserver(self, forKeyPath: #keyPath(urlConnection), options: [.new, .old], context: nil)
    }

    override func viewDidAppear(_ animated: Bool) {
        let request = URLRequest(url: URL(string: "https://google.com")!)
        urlConnection = NSURLConnection(request: request, delegate: self, startImmediately: false)
    }
    
    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
    }
}

extension ViewController: NSURLConnectionDelegate, NSURLConnectionDataDelegate {
}

@kazuhiro4949
Copy link

Could you tell me whether the assertion has a problem or not?
It is an internal specification of KVO.

@morganchen12
Copy link
Contributor

@kazuhiro4949 can you share the stack trace of your repro example's crash? GoogleUtilities shouldn't be conflicting with NSURLConnection.

@kazuhiro4949
Copy link

kazuhiro4949 commented Nov 7, 2018

@morganchen12
This is the stack track. ViewController is an entry point in FirebaseAssert project.

 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The original class must be the same as the class returned by object_setClass'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010a06e1bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x000000010960c735 objc_exception_throw + 48
	2   CoreFoundation                      0x000000010a06df42 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x0000000108ad4877 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   GoogleUtilities                     0x0000000109194bc0 -[GULObjectSwizzler swizzle] + 1312
	5   FirebaseAssert                      0x0000000108123cbd __55-[FPRNSURLConnectionDelegateInstrument registerObject:]_block_invoke + 1231
	6   libdispatch.dylib                   0x000000010b31d602 _dispatch_client_callout + 8
	7   libdispatch.dylib                   0x000000010b32b653 _dispatch_lane_barrier_sync_invoke_and_complete + 132
	8   FirebaseAssert                      0x00000001081237c7 -[FPRNSURLConnectionDelegateInstrument registerObject:] + 116
	9   FirebaseAssert                      0x0000000108126826 __InstrumentInitWithRequestDelegateStartImmediately_block_invoke + 162
	10  FirebaseAssert                      0x00000001080d9f5f $SSo15NSURLConnectionC7request8delegate16startImmediatelyABSg10Foundation10URLRequestV_ypSgSbtcfcTO + 255
	11  FirebaseAssert                      0x00000001080d870d $SSo15NSURLConnectionC7request8delegate16startImmediatelyABSg10Foundation10URLRequestV_ypSgSbtcfC + 61
	12  FirebaseAssert                      0x00000001080d8637 $S14FirebaseAssert14ViewControllerC13viewDidAppearyySbF + 359
	13  FirebaseAssert                      0x00000001080d8753 $S14FirebaseAssert14ViewControllerC13viewDidAppearyySbFTo + 51
	14  UIKitCore                           0x000000010d224544 -[UIViewController _setViewAppearState:isAnimating:] + 947
	15  UIKitCore                           0x000000010d22727d __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 42
	16  UIKitCore                           0x000000010d2255e2 -[UIViewController _executeAfterAppearanceBlock] + 78
	17  UIKitCore                           0x000000010d84920e _runAfterCACommitDeferredBlocks + 634
	18  UIKitCore                           0x000000010d837b2c _cleanUpAfterCAFlushAndRunDeferredBlocks + 384
	19  UIKitCore                           0x000000010d8582de __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 153
	20  CoreFoundation                      0x0000000109fd362c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	21  CoreFoundation                      0x0000000109fd2de0 __CFRunLoopDoBlocks + 336
	22  CoreFoundation                      0x0000000109fcd654 __CFRunLoopRun + 1284
	23  CoreFoundation                      0x0000000109fcce11 CFRunLoopRunSpecific + 625
	24  GraphicsServices                    0x0000000112cfd1dd GSEventRunModal + 62
	25  UIKitCore                           0x000000010d83d81d UIApplicationMain + 140
	26  FirebaseAssert                      0x00000001080dabe7 main + 71
	27  libdyld.dylib                       0x000000010b393575 start + 1
	28  ???                                 0x0000000000000001 0x0 + 1
)

@paulb777
Copy link
Member

Fix planned to go out with GoogleUtilities 5.3.5

@firebase firebase locked and limited conversation to collaborators Oct 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants