If project is null, don't call ensureDocumentWritable.
Don't try to write buffers if they're not populated.