wordpress-mobile / WordPress-iOS

WordPress for iOS - Official repository
http://ios.wordpress.org/
GNU General Public License v2.0
3.69k stars 1.12k forks source link

Share extension crashes on consecutive uses #20873

Open guarani opened 1 year ago

guarani commented 1 year ago

Expected behavior

Sharing to the Jetpack app shouldn't cause a crash.

Actual behavior

Sharing causes a crash the 2nd time it's used.

Steps to reproduce the behavior

These are the steps to reproduce the crash (reproducible on 2 out of 2 attempts):

  1. Shared text (highlight text in an online text editor, long-press, Share, choose Jetpack)
  2. Once the JP share sheet opens, close it
  3. Open a different app and shared text (highlighted text in notes field of Contacts app, long-press, Share, choose Jetpack)
  4. Once the JP share sheet opens, close it
  5. Share extension crashes in Xcode
* thread #31, queue = 'com.apple.NSURLSession-delegate', stop reason = EXC_BREAKPOINT (code=1, subcode=0x10c6c11b8)
    frame #0: 0x000000010c6c11b8 CoreData`_PFAssertSafeMultiThreadedAccess_impl + 520
    frame #1: 0x000000010c6c8f90 CoreData`-[NSManagedObjectContext executeRequest:error:] + 2552
    frame #2: 0x000000010c61f488 CoreData`__C.NSManagedObjectContext.fetch<τ_0_0 where τ_0_0: __C.NSFetchRequestResult>(__C.NSFetchRequest<τ_0_0>) throws -> Swift.Array<τ_0_0> + 80
  * frame #3: 0x00000001029d80bc Jetpack`SharedCoreDataStack.fetchSessionUploadOps(taskIdentifier=1, sessionID="group.org.wordpress.06C9B0C5-26E7-427C-9551-6143F857DD49", self=0x00000002951df010) at SharedCoreDataStack.swift:194:44
    frame #4: 0x00000001025d2270 Jetpack`ShareExtensionSessionManager.urlSession(session=0x0000000295cb37f0, task=0x00000002952a2f40, error=nil, self=0x0000000295c8f920) at ShareExtensionSessionManager.swift:338:45
    frame #5: 0x00000001025d3034 Jetpack`@objc ShareExtensionSessionManager.urlSession(_:task:didCompleteWithError:) at <compiler-generated>:0
    frame #6: 0x00000001168540e0 CFNetwork`___lldb_unnamed_symbol2749 + 32
    frame #7: 0x000000011ccec528 libdispatch.dylib`_dispatch_call_block_and_release + 24
    frame #8: 0x000000011ccedd50 libdispatch.dylib`_dispatch_client_callout + 16
    frame #9: 0x000000011ccf6014 libdispatch.dylib`_dispatch_lane_serial_drain + 924
    frame #10: 0x000000011ccf6da4 libdispatch.dylib`_dispatch_lane_invoke + 480
    frame #11: 0x000000011cd04b74 libdispatch.dylib`_dispatch_workloop_worker_thread + 1716
    frame #12: 0x00000001b1834878 libsystem_pthread.dylib`_pthread_wqthread + 284

Tested on iPhone simulator, iOS 16.4, Jetpack iOS 0520842897ec3f11868fef24e3f76d916f4b21c3
kean commented 1 year ago

Dupe: https://github.com/wordpress-mobile/WordPress-iOS/issues/20865 It's a concurrency error, but it shouldn't cause frequent/reproducible crashes in production I'm going to close my issue because there is more details here.

guarani commented 1 year ago

Ah, I missed your issue. Thanks for merging @kean.