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

2.1 DB1: Crash when inserting image Blobs to objects in embedded array in Swift #2162

Closed
rajagp opened this Issue Jun 3, 2018 · 1 comment

Comments

Projects
None yet
4 participants
@rajagp
Contributor

rajagp commented Jun 3, 2018


  • Version: CBL 2.1 CB1
  • Client OS: iOS / Swift
  • Server: N/A

This is my JSON Document . Includes an embedded array . Each member of the array is a dictionary= one element is Blob type.

Example :


{
“type”:”list”,
“items”:[
{
“key”:”foo”
“value”:”bar”
“image”: Blob
}
]
}

Sample code to reproduce:

      let imageData = try? Data.init(contentsOf: Bundle.main.url(forResource: "cb", withExtension: "png")!)
       let arr1 = [["key":"key","value":"value","image":Blob.init(contentType: "image/png", data: imageData!)]]
        mutableDoc.setArray(MutableArrayObject.init(data: arr1),  forKey: ListDocumentKeys.items.rawValue)
        do {
            try? db.saveDocument(mutableDoc)
     
        }
        catch {
            print(error)
        }

Observing :

Crash :

2018-06-02 11:00:36.912772-0400 CBLP2PAdvertiser[52637:37350194] *** NSForwarding: warning: object 0x60400003eb40 of class 'CouchbaseLiteSwift.Blob' does not implement methodSignatureForSelector: -- trouble ahead
Unrecognized selector -[CouchbaseLiteSwift.Blob cbl_toCBLObject]
2018-06-02 11:00:36.913400-0400 CBLP2PAdvertiser[52637:37350194] Unrecognized selector -[CouchbaseLiteSwift.Blob cbl_toCBLObject]

Stack Trace : https://gist.github.com/rajagp/3931c71af06fe3a2d8b81f4a1ddca252

@rajagp rajagp added the crash! label Jun 3, 2018

pasin added a commit that referenced this issue Jun 6, 2018

Fix converting nested swift dictionary/array to CBL objects
Detected nested native dictionary and array and properly convert them to CBL Object.

#2162
@pasin

This comment has been minimized.

Contributor

pasin commented Jun 6, 2018

@rajagp I have fixed the issue. Please try it out.

@pasin pasin closed this Jun 6, 2018

@Sandychuang8 Sandychuang8 removed the backlog label Jun 6, 2018

@pasin pasin added this to the 2.1 milestone Jun 6, 2018

@djpongh djpongh modified the milestones: 2.1, 2.1.0 Jun 21, 2018

@pasin pasin added the bug label Jul 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment