What is PBItemCollectionServicer?

后端 未结 6 948
孤街浪徒
孤街浪徒 2020-12-30 00:48

I searched SO ,find nothing about PBItemCollectionServicer.

My question become form my app crash(because of memory rise violently), then print:

相关标签:
6条回答
  • 2020-12-30 00:56

    "PBItemCollectionServicer connection disconnected." also logs when using iOS 11 table view drag-and-drop and completing a drop. It's benign there, from all I've observed.

    0 讨论(0)
  • 2020-12-30 01:02

    For me, the error occurred when PHAssetCollection fetchAssetCollectionsWithType : called with a block predicate:

    PHFetchOptions *fetchOptions = PHFetchOptions.new;
    // correct
    fetchOptions.predicate = [NSPredicate predicateWithFormat:@"localizedTitle = %@", targetAlbumName];
    // wrong
    // crash with the error message "PBItemCollectionServicer connection disconnected."
    //fetchOptions.predicate = [NSPredicate predicateWithBlock:xxx];
    PHAssetCollection * assetCollection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:fetchOptions].firstObject;
    
    0 讨论(0)
  • 2020-12-30 01:12

    Well, I guess those annoying PBItemCollectionServicer logs appear seconds after you copied (Command+ C) something into your iOS devices or iOS simulator which is running apps via Xcode.

    The "universal clipboard" service (seems to) collects strings or images to share between your own iCloud devices (Mac, iOS devices ...)

    It works in Sierra & iOS 10 environment Check this article

    This log happens only when under simulator/iOS device while running on Xcode, I think.

    I don't know why Xcode team let this somewhat should-be-hidden log displayed... for developers? But couldn't find any documentation... blah blah

    0 讨论(0)
  • 2020-12-30 01:12

    Firstly, this is not an answer to the question. And I failed to find one. It's just some information I think may be helpful for someone who can dig into this and find an answer.

    I was tinkering with the copy(_:), cut(_:) and paste(_:) functions of UITextField. Almost every time I did copy/cut/paste in in field, the Xcode gave this message:

    2020-07-17 15:45:38.796510+0800 MyApp[3062:1763915] [general] Connection to daemon was invalidated
    2020-07-17 15:45:54.179188+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
    2020-07-17 15:46:53.097783+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
    2020-07-17 15:46:57.180499+0800 MyApp[3062:1763859] PBItemCollectionServicer connection disconnected.
    2020-07-17 15:48:34.901502+0800 MyApp[3062:1764656] PBItemCollectionServicer connection disconnected.
    

    The only relevant code is an extension to UITextField:

    extension UITextField {
        open override func copy(_ sender: Any?) {
            print(sender)
            print(text)
        }
    
        open override func paste(_ sender: Any?) {
            print(sender)
            print(text)
        }
        
        open override func cut(_ sender: Any?) {
            print(sender)
            print(text)
        }
    }
    

    And none of them was called. How weird. Then I commented out this extension, and to my surprise, Xcode still gave the exactly same message. Anyway, after I searched here and there, I found this in Apple Developer Forums, which is discussion about the failure of UIDropInteraction with the same error message. As all the other answers mostly talked about UIPasteboard, I think it is necessary to put it here although it doesn't contain a solution or answer.

    I tried running on both Simulator(13.5) and device(13.4.1), with Xcode 11.5, and got the same error message.

    0 讨论(0)
  • 2020-12-30 01:13

    I found that when working with drag and drop this error gets cleared up when adding

    view.addInteraction(UIDropInteraction(delegate: self))
    

    to the viewDidLoad of the view you are dropping into.

    0 讨论(0)
  • 2020-12-30 01:18

    I was receiving:

    Console Log: "PBItemCollectionServicer connection disconnected." 
    

    all of a sudden while debugging an iPhone app while connected via the USB cable to my MacBook.

    After a bit of searching it turned out that it was hanging for some time because of this line of code where I was clearing the pasteboard:

    [pasteBoard setValue:@"" forPasteboardType:UIPasteboardNameGeneral];
    

    After a lot of google searching without any luck I noticed that it only happens when the iPhone was connected to my Mac.

    It turned out to be the shared clipboard causing the hang/delay and log message.

    If you turn off "Handoff" on the iPhone (Settings/General/Handoff) and Mac (System Preferences/General/Allow Handoff) then the problem was resolved.

    The problem also goes away when you disconnect the USB cable from the Mac so it doesn't affect regular use.

    0 讨论(0)
提交回复
热议问题