David U David U - 4 months ago 40
iOS Question

Crash in PPSSignatureView

I’m using Xcode 6 to develop an app for iOS 7. I’m having an issue with the

PPSSignatureView
component downloaded from GitHub. I’m presenting the signature view in a popover. The first time the signature view displays it works and everything is fine. But when I redisplay the same popover a 2nd time, I get an error in
PPSSignatureView.m
:

#import <OpenGLES/ES2/glext.h>

// Append vertex to array buffer
static inline void addVertex(uint *length, PPSSignaturePoint v) {
if ((*length) >= maxLength) {
return;
}

GLvoid *data = glMapBufferOES(GL_ARRAY_BUFFER, GL_WRITE_ONLY_OES);
memcpy(data + sizeof(PPSSignaturePoint) * (*length), &v, sizeof(PPSSignaturePoint));
glUnmapBufferOES(GL_ARRAY_BUFFER);

(*length)++;
}


On the 2nd presentation,
glMapBufferOES()
returns
NULL
and
memcpy()
generates the error

Thread 1:EXC_BAD_ACCESS(code=1, address=0x0)


I do not know the OpenGL library. I have read some SO entries about OpenGL, Xcode 6 and iOS8, but those issues refer to compile time errors and I am having a run time error. Does anyone understand what is going on?

Thanks

Edit: I know the error looks like a low-memory error. I'm not getting a memory warning from iOS and I'm having trouble believing that's the real problem. Also, on the second and subsequent presentations, if I do a long press on the signature view before I start drawing then the signature view does not crash. But calling the long press action in code on the second presentation does not prevent the crash.

Here's the long press code:

- (void)longPress:(UILongPressGestureRecognizer *)lp {
[self erase];
}


- (void)erase {
length = 0;
dotsLength = 0;
self.hasSignature = NO;

[self setNeedsDisplay];
}

Answer

Thanks for your reply. I fixed the error by adding the call

[signatureView erase]

immediately after presenting the popover containing the signature view.