2016-10-05 1 views
1

내 응용 프로그램이 백그라운드에 들어갈 때 나는 GCDWebServer에서 충돌 (3.3.3)을 받고 있어요 :충돌은 GCDWebServer의 경우 응용 프로그램은 입력 배경

#3 0x000000010041ea80 in -[GCDWebServer dealloc] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:221 
#4 0x00000001004248b8 in __destroy_helper_block_() 
#5 0x000000018dd52a28 in _Block_release() 
#6 0x00000001020ad21c in _dispatch_client_callout() 
#7 0x00000001020b2284 in _dispatch_main_queue_callback_4CF() 
#8 0x000000018ee21f2c in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__() 
#9 0x000000018ee1fb18 in __CFRunLoopRun() 
#10 0x000000018ed4e048 in CFRunLoopRunSpecific() 
#11 0x00000001907d1198 in GSEventRunModal() 
#12 0x0000000194d28628 in -[UIApplication _run]() 
#13 0x0000000194d23360 in UIApplicationMain() 
#14 0x000000010009243c in main at project/main.m:10 
#15 0x000000018dd305b8 in start() 
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial) 
#0 0x00000001020b8ba4 in _dispatch_queue_push() 
#1 0x0000000100424680 in -[GCDWebServer _stop] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:734 
#2 0x0000000100424a10 in -[GCDWebServer _didEnterBackground:] at project/Pods/GCDWebServer/GCDWebServer/Core/GCDWebServer.m:746 

특정 라인은 다음과 같습니다

GWS_DCHECK(_options == nil); // The server can never be dealloc'ed while running because of the retain-cycle with the dispatch source 

를이 _options 사전은 nil이어야합니다 (예 : 서버를 중지해야 함). _options은이 코드 경로에서 nil으로 설정되지 않습니다. - stop에서는 nil로 설정되지만 - _stop에서는 nil로 설정되지 않습니다.

다른 사람들이 알아 차 렸을 것 같은데 아마도 뭔가 빠졌을 것입니다.

답변

1

나는 동일한 문제가있었습니다. 나는 함수를 저장하는 대신 내 클래스의 정적 변수에 서버를 저장하는 방법으로 해결했습니다.

그것은하지 않습니다 작품 :

class Server { 
     static func initialize() { 
      let webServer = GCDWebServer() 
      ... 
      webServer?.start(withPort: 8081, bonjourName: nil) 
     } 
    } 

그것은 작품 :

class Server { 
     static let webServer = GCDWebServer() 
     static func initialize() { 
      ... 
      webServer?.start(withPort: 8081, bonjourName: nil) 
     } 
    } 
+0

아니 아스 커 대답으로이를 표시하지 않은,하지만 난 같은 문제에 직면하고 나는 그것을 확인할 수 있습니다 확실한 이유 이것은 나를 위해 작동합니다. 나는 objc를 사용하고 있으므로, 내가 한 것은 webServer에 대한 강력한 참조를 작성하는 것이고, 이는 문제를 해결합니다. – wahkiz