Added the setTimeout to the existing code as below

ThreadUI.cleanFields(true);

blobs.forEach(function(blob, idx) {
  var attachment = new Attachment(blob, {
    name: names[idx],
    isDraft: true
  });
  setTimeout(function() {
    Compose.append(attachment);
  },1000);
});

With this change (by adding setTimeout)
1. The delay when navigating from Gallery screen to Messages compose screen is avoided
2. Need to test more scenarios to check the crash.