Hi Rick,
Thank you for your time on checking these changes.
I have already tried with below modifications

function insertAttachments() {
    window.removeEventListener('hashchange', insertAttachments);

    ThreadUI.cleanFields(true);

    blobs.forEach(function(blob, idx) {
      var attachment = new Attachment(blob, {
        name: names[idx],
        isDraft: true
      });
      Compose.append(attachment);
    });

When we select images in Gallery application -> select share -> It is taking time to navigate from Gallery app to Messages compose screen -> In the mean time if we press the share button again -> Crash is happening.