Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 19    Views: 55

Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
06/07/14 02:14 PM (10 years ago)

PDF Doc plugin crashing app

I am creating a new app using BT3.0 on a selfhost. My app includes multiple pdf files using PDF Doc plugin. I started testing it and opened and closed about 30 pdf files one after the next and around the 30th pdf the app crashed due to memory pressure. Each pdf is on average about 300kb so not very large. I had this problem previously on a different BT 2.1.9 app which was resolved by replacing the pdfDoc.h, pdfDoc.m, appDelegate.h & appDelegate.m files but now that we are on BT3.0 will this fix still work and if not is there another fix that will cause the pdf's to release from memory as soon as they close.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/07/14 04:55 PM (10 years ago)
This is 'supposed' to release memory no longer used in your app... You will want to put this 'outside' of any other method; it is a method in itself. - (void)didReceiveMemoryWarning { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"didReceiveMemoryWarning: %@", self]]; [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } Maybe it will help... maybe it won't. But it's worth a shot. Cheers! -- Smug
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
06/07/14 07:04 PM (10 years ago)
We (David) fixed this for a big name client's app. If Smug's code doesn't fix it I can send you the plugin that was fixed. Only prob is I'm out of town until the 18th. Tim
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/08/14 12:01 AM (10 years ago)
Thanks Smug and Tim for your replies. Smug I'll try your code and let you know what happens. Tim is the fix you're referring to the same one you gave me previously for my BT 2.1.9 app or do you have an additional one for BT3.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/08/14 12:11 PM (10 years ago)
@Smug I inserted your code right near the end of the BT_screen_pdfDoc.m file but unfortunately the app still crashes after about 30 pdf's are opened and closed.
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
06/08/14 02:13 PM (10 years ago)
If I gave you one already that's it. Maybe do a compare and see what the difference is, maybe it can be used in the 3.0 project too.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/08/14 03:33 PM (10 years ago)
Thanks Tim I tried to use it as is in BT3.0 but xcode didn't like it, and some of the statements used are no longer valid for BT3 but I will do further research cause I have to fix this for my client.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/09/14 02:51 PM (10 years ago)
Thanks Tim I tried to use it as is in BT3.0 but xcode didn't like it, and some of the statements used are no longer valid for BT3 but I will do further research cause I have to fix this for my client.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
06/09/14 03:05 PM (10 years ago)
Once you figure it out, will you send me the corrected version of the file? I will upload it via the Admin panel so we all have it. It sounds like this fix never was put into the plugin.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/10/14 02:04 AM (10 years ago)
Hi Susan I have tried but haven't been able to sort this out. I really need one of the experts to look at this plugin. The fix David did previously for Tim Wolf in BT 2.1.9 worked like a charm but now with BT3 throws out errors in xcode.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
06/13/14 01:20 PM (10 years ago)
I set up a document compare of the two .m files. Try changing line 244 from this: [self initLoad]; To this: [self performSelector:@selector(initLoad) withObject:nil afterDelay:.2]; Let me know if that works. If it does, I can update the plugin with the change. I am not sure this change alone will do the trick--the code that David gave Tim also modifies some core files.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/13/14 02:07 PM (10 years ago)
Thanks for your help Susan, I tried this but it's unfortunately still crashing.
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
06/13/14 02:33 PM (10 years ago)
Oh, well. With this app I am working on, I went through every single PDF to make sure it was there--all at one time. There are around 100 PDFs. And it didn't crash. Any other symptoms you can share? Are you using special characters in the PDF file names or screen names? The Buzztouch code is remarkably forgiving, but every now and again I have to remove a special character from a file name.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/13/14 02:34 PM (10 years ago)
Thanks for your help Susan, I tried this but it's unfortunately still crashing.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/24/14 03:07 PM (10 years ago)
I have tried making a few different changes but it is still crashing and don't know what more to try. My app is focused around product label pdf's that contain images and text. I created the pdf files by using the save as option from graphic design program with a lot of image downsampling and compression so each pdf averages around 300kb. I thought it might be the images that was causing the problem so I tried opening 3 of the pdf's which which contained no images multiple times and when I got to about the 30 opening the app crashed I had used ® symbol in BT screen name and description so removed it but no success there either. Lastly I also tried to use files which had no security settings from Acrobat on them but that didn't work either. I have to give this app to my client on Thurs for testing and don't know what to do.
 
WolfTimJ
buzztouch Evangelist
Profile
Posts: 810
Reg: Feb 20, 2011
Rockwall, TX
17,400
like
06/24/14 05:09 PM (10 years ago)
Sherry, I found the email that David sent me last year with 4 files that fixed this problem. Send me your email and I will forward them along. I'll also send to Susan so she can help you with any modification to the included files. If this does fix it someone really should try and disseminate this fix. Sherry, send me an email to: tim.w at apps4ems.com and I'll send what I have. Tim
 
Susan Metoxen
buzztouch Evangelist
Profile
Posts: 1706
Reg: May 01, 2011
Hopkins, Minnes...
26,260
like
06/24/14 08:43 PM (10 years ago)
I looked up the size of the PDFs in my apps, and they are about a third of the size of your PDFs, although the size varies considerably. So the size of the PDFs could be a factor. One time I had a problem with PDFs in an app, and I had to resave the PDFs as "Optimized". But that was a different situation in that certain PDFs would not open at all.
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
07/19/14 10:43 AM (10 years ago)
WHOO HOO I found the solution to this problem :-) can't tell you how relieved I am. I've opened 120 pdf's one after the other with no crash where previously the limit before a crash was 30. All that needs to be done is to add the following code right at end of BT_screen_pdfDoc.m on line 817. I didn't need to make any changes to any other file. - (void)viewDidDisappear:(BOOL)animated { [webView removeFromSuperview]; webView = nil; } I added it below dealloc and above @end: //dealloc -(void)dealloc { webView.delegate = nil; [webView stopLoading]; } - (void)viewDidDisappear:(BOOL)animated { [webView removeFromSuperview]; webView = nil; } @end
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
07/19/14 02:18 PM (10 years ago)
Sweet! Copying this to my snippets. Thanks! Glad to see you got it going :) Cheers! -- Smug
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
07/20/14 10:04 AM (10 years ago)
After posting the fix above which I'd tested with no problems on a ipad mini with retina display I tried testing it on an ipad2 and although it didn't crash the app like previously the ipad2 did struggle after about 50 pdf's and would only display a white screen and pretty much froze everything else so I added Smug's suggestion (WAY TO GO SMUG!!!) and voila ipad 2 functioned without a hitch. Susan - for the plugin update this what I added. - (void)didReceiveMemoryWarning { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"didReceiveMemoryWarning: %@", self]]; [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } - (void)viewDidDisappear:(BOOL)animated { [webView removeFromSuperview]; webView = nil; } I added it below dealloc and above @end: //dealloc -(void)dealloc { webView.delegate = nil; [webView stopLoading]; } - (void)didReceiveMemoryWarning { [BT_debugger showIt:self theMessage:[NSString stringWithFormat:@"didReceiveMemoryWarning: %@", self]]; [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview // Release anything that's not essential, such as cached data } - (void)viewDidDisappear:(BOOL)animated { [webView removeFromSuperview]; webView = nil; } @end
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.