inkling/Subliminal — pull request #231 by justinseanmartin (2014-07-10 00:16:41+00:00)
Title: Try and handle NSData encoding failures

The issue with the current logic is that it assumes that each individual data buffer will successfully convert into a UTF8 string. However, this is not the case if instruments flushes the pipe in the middle of a UTF8 multi-byte character, and will lead to an exception when we try to appendString:nil to buffer.

The easy solution to this crash is that if the data buffer doesn't convert, then wait for the next data buffer. The assumption is that before the pipe is closed, we'll receive a buffer that can be successfully converted.

FYI - One potential issue with this solution is that if the Instruments output has a lot of non-ASCII text in it, the data buffer will be more likely to fail conversion (and grow the buffer in memory while doing so). This is could possibly happen with a non-English localized app-under-test (e.g. Japanese). This could be even more problematic if the OSX system language were set to a different language.