Невозможно определить специализированную статистику c сбой - PullRequest
0 голосов
/ 03 августа 2020

Я сталкиваюсь с этим sh крахлитиком, который я не могу понять. Имя схемы приложения - DM C, а заголовок отчета о сбоях - "special stati c OfflineManager.putData (path: content :)" . Вот отчет cra sh

    Crashed: com.apple.main-thread
0  libsystem_kernel.dylib         0x197ced2f0 fsync + 8
1  Foundation                     0x1982c5054 _NSWriteDataToFileWithExtendedAttributes + 580
2  Foundation                     0x1982ddf48 writeStringToURLOrPath + 220
3  libswiftFoundation.dylib       0x1cd136600 StringProtocol.write(to:atomically:encoding:) + 124
4  DMC                            0x1011acfcc specialized static OfflineManager.putData(path:content:) + 47 (OfflineManager.swift:47)
5  DMC                            0x1011aea0c specialized static OfflineManager.putModelData<A>(model:path:) + 81 (OfflineManager.swift:81)
6  DMC                            0x1011a7970 specialized SyncManager.appDidTerminate() + 4301437296 (<compiler-generated>:4301437296)
7  CoreFoundation                 0x197e52644 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
8  CoreFoundation                 0x197e5268c ___CFXRegistrationPost1_block_invoke + 64
9  CoreFoundation                 0x197e519e4 _CFXRegistrationPost1 + 368
10 CoreFoundation                 0x197e516bc ___CFXNotificationPost_block_invoke + 88
11 CoreFoundation                 0x197dce414 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1412
12 CoreFoundation                 0x197e5101c _CFXNotificationPost + 1236
13 Foundation                     0x1981b0974 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
14 UIKitCore                      0x19bfa2de8 __47-[UIApplication _applicationDidEnterBackground]_block_invoke + 312
15 UIKitCore                      0x19b967320 +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] + 168
16 UIKitCore                      0x19bfa2ba4 -[UIApplication _applicationDidEnterBackground] + 116
17 UIKitCore                      0x19b740a4c __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 + 860
18 UIKitCore                      0x19bbf02dc _UIScenePerformActionsWithLifecycleActionMask + 100
19 UIKitCore                      0x19b740654 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 196
20 UIKitCore                      0x19b7400a8 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 288
21 UIKitCore                      0x19b740480 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 740
22 UIKitCore                      0x19b73fd40 -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 336
23 UIKitCore                      0x19b7441dc __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke_2 + 188
24 UIKitCore                      0x19bb143a0 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 812
25 UIKitCore                      0x19bc09720 _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 244
26 UIKitCore                      0x19b743f38 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 140
27 UIKitCore                      0x19bc0961c _UISceneSettingsDiffActionPerformActionsWithDelayForTransitionContext + 100
28 UIKitCore                      0x19b743da0 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 376
29 UIKitCore                      0x19b5b3f74 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 636
30 UIKitCore                      0x19b5b2b14 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 248
31 UIKitCore                      0x19b5b3cac -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 220
32 UIKitCore                      0x19bb39afc -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 464
33 FrontBoardServices             0x19d06e0a8 -[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:] + 528
34 FrontBoardServices             0x19d092684 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke_2 + 120
35 FrontBoardServices             0x19d077bfc -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 232
36 FrontBoardServices             0x19d0925b8 __88-[FBSWorkspaceScenesClient sceneID:updateWithSettingsDiff:transitionContext:completion:]_block_invoke + 184
37 libdispatch.dylib              0x197bbc524 _dispatch_client_callout + 16
38 libdispatch.dylib              0x197b65434 _dispatch_block_invoke_direct$VARIANT$mp + 224
39 FrontBoardServices             0x19d0b6850 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
40 FrontBoardServices             0x19d0b651c -[FBSSerialQueue _queue_performNextIfPossible] + 404
41 FrontBoardServices             0x19d0b6a44 -[FBSSerialQueue _performNextFromRunLoopSource] + 28
42 CoreFoundation                 0x197e74c18 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
43 CoreFoundation                 0x197e74b70 __CFRunLoopDoSource0 + 80
44 CoreFoundation                 0x197e742f8 __CFRunLoopDoSources0 + 184
45 CoreFoundation                 0x197e6f328 __CFRunLoopRun + 788
46 CoreFoundation                 0x197e6ece8 CFRunLoopRunSpecific + 424
47 GraphicsServices               0x1a1fb938c GSEventRunModal + 160
48 UIKitCore                      0x19bf9d444 UIApplicationMain + 1932
49 DMC                            0x1011677d0 main + 11 (AppDelegate.swift:11)
50 libdyld.dylib                  0x197cf68f0 start + 4

И это метод, при котором происходит сбой. Насколько я понимаю, эта ошибка sh, вероятно, происходит из-за того, что приложение пытается связаться с освобожденным объектом. Однако я не могу понять, где в этом блоке кода это может происходить.

static func putData(path: String, content: String) {
        var content = content

        guard let userDirectory = getUserDirectory() else { return }
        var basePath: String = "\(userDirectory)/\(path)"
      
        var basePathSplitComponents = basePath.split(separator: "/")
        let fileName = basePathSplitComponents[basePathSplitComponents.count - 1]
        basePathSplitComponents.remove(at: basePathSplitComponents.count - 1)
        basePath = basePathSplitComponents.joined(separator: "/")
        let baseDataStoragePath = OfflineManager.getDocumentsDirectory().appendingPathComponent(
            basePath, isDirectory: true
        )

        // Check if the directory exists
        if !FileManager.default.directoryExistsAtPath(baseDataStoragePath.absoluteString) {
            DDLogInfo("Directory for \(basePath) doesn't exist")
            do {
                try FileManager.default.createDirectory(
                    at: baseDataStoragePath,
                    withIntermediateDirectories: true,
                    attributes: nil
                )
                DDLogInfo("Created directory for  \(basePath)")
            } catch {
                DDLogError(" Errror creating directory \(error.localizedDescription)")
                return
            }
        }

        // Create JSON file for the data
        let filePath = "\(basePath)/\(fileName)"
        let filename = getDocumentsDirectory().appendingPathComponent("\(filePath).json")
        do {
            try content.write(to: filename, atomically: true, encoding: .utf8) // Line where the app crashes
            DDLogInfo("Created JSON file at \(filename)")
        } catch {
            DDLogError("Unable to create \(filePath).json \(error.localizedDescription)")
            return
        }
    }

Большое спасибо за помощь :)

...