Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2286] Ti.Facebook iOS: Sending Ti.Blob's in requestWithGraphPath throws mutating-error

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-08-29T03:49:09.000+0000
Affected Version/sRelease 5.1.2, Release 5.3.0, Release 5.4.0, Release 5.2.1
Fix Version/sRelease 6.0.0
ComponentsFacebook
Labelsfacebook, graph, mutating
ReporterHans Knöchel
AssigneeHans Knöchel
Created2016-08-26T23:20:09.000+0000
Updated2018-08-06T17:49:12.000+0000

Description

When using the method requestWithGraphPath to send images to the graph, we unpack the blobs to NSData types internally. So far so good, but while doing that, we fast-iterate through the dictionary of parameters and mutate the value if it is a blob. That needs to be fixed. More infos: http://stackoverflow.com/questions/39152131/appcelerator-facebook-module-error-posting-photo-on-ios *Expected behavior*: The requestWithGraphPath method succeeds, a new photo is uploaded to Facebook *Actual behavior*: The app fails with a *** Collection <__NSDictionaryM: 0x14ee27430> was mutated while being enumerated. error

Comments

  1. Hans Knöchel 2016-08-26

    PR: https://github.com/appcelerator-modules/ti.facebook/pull/61 Demo:
       var fb = require("facebook");
       fb.initialize();
       
       var win = Ti.UI.createWindow({
           backgroundColor: "#fff"
       });
       var btn = Ti.UI.createButton({
           title: (fb.loggedIn) ? "Request write permissions and submit" : "Login"
       });
        
       btn.addEventListener("click", function() {
           if (fb.loggedIn) {
               requestPublishPermissions();
           } else {
               fb.permissions = ['email'];
               fb.authorize();
           }
       });
        
       fb.addEventListener("login", function(_e) {
           if (!_e.success) {
               btn.setTitle("Login");
               Ti.API.error("Login cancelled/failed!");
               Ti.API.error(_e);
               return;
           } else {
               Ti.API.info("Login succeeded");
               btn.setTitle("Request write permissions and submit");
           }        
       });
       
       function requestPublishPermissions() {
           fb.requestNewPublishPermissions(['publish_actions'], fb.AUDIENCE_ONLY_ME, function(e) {
               if (!e.success) {
                   alert("Publish permissions denied!");
                   return;
               }
                       
               var blob = Ti.UI.createView({
                   width: 500,
                   height: 500,
                   backgroundColor: "green"
               }).toImage();
               
               var args = {
                   picture: blob,
                   caption: "Great green view"
               };
               
               fb.requestWithGraphPath('me/photos', args, "POST", showRequestResult);
           });
       
       }
       
       function showRequestResult(e) {
           alert("Photo has been submitted, check your facebook photo album");
           Ti.API.info(e);
       }
        
       win.add(btn);
       win.open();
       
    A compiled version of the module is attached to the PR. [~cng] I would like to have this in 6.0.0, let me know if that's ok and I'll prepare the SDK-PR's.
  2. Chee Kiat Ng 2016-08-29

    CR and FT passed. APPROVED. (Good fix btw). Please back port for 6.0.0. And also indicate *Expected Result* and any additional helpful information in your test so that QE can verify easily later.
  3. Hans Knöchel 2016-08-29

    Information updated, new Ti.Facebook version released on Github, prepackaged module updated for master and 6_0_X.
  4. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source