6

I am trying to draw svg maps using code generated through paintcode. The code is working fine when I am running it using simulator. But If I run it in device (iPad), it is crashing in drawCanvas method giving

Warning : Could not load any Objective-C class information. This will significantly reduce the quality of type information available.

Warning Screen Shot

Click here to check the warning Screen Shot

I am drawing map in storyboard where in view there is a scrollview and inside that one image View. I have added one StyleKitClass object (StyleKitClass is an NSObject class generated using PaintCode app) with which I connected via IBOutlet Collections to imageView.

Outlet Connections

Click here to view Outlet Connections

If anyone knows then please help me with the solution.

pckill
  • 3,709
  • 36
  • 48
PriyaJain
  • 99
  • 1
  • 2
  • 6
  • 1
    That warning is not the cause for crash. It’s just a message from debugger. Could you try to enable Address Sanitizer and run the code again? – Tricertops Jul 26 '16 at 07:44
  • I enabled Address Sanitizer. But it is not printing anything in the console. Also, when I print memory history with the memory address, it is not giving any value. – PriyaJain Jul 26 '16 at 10:39
  • But I found one thing at the time of warning in + (void)drawCanvas1 and that is, in the variable view the address for styleKit class is **self=(class)0x0**. It seems that that the StyleKit is deallocated. – PriyaJain Jul 26 '16 at 10:42
  • Never seen this issue before. Looks like the crash occurs before this method starts, so `self` contains some random value (0x20 on your screenshot). Are you using ARC? Did you modify generated code? Try calling this method from different place to see what happens. – Tricertops Jul 26 '16 at 11:05
  • No I haven't modified the code generated. I just dragged StyleKit classes in my project and started using as explained in the tutorials. Also, I am not using ARC. I will try calling the method from different place. – PriyaJain Jul 26 '16 at 11:17
  • Try adding `-dealloc` method to the StyleKit and print when it is deallocated – maybe before this crash?. Also, you should use ARC. – Tricertops Jul 26 '16 at 11:55
  • I tried to reproduce the same error, by calling a method to sort an array without for loop. That is a method calling itself again and again. When array contains 200 values it displayed same error in iphone. I noticed its working good in simulator, once we change the array to 400 values, it also crahes in the simulator with same error – Sujananth Feb 26 '18 at 17:55

3 Answers3

6

I work at PixelCut, we make PaintCode.

After you sent us the project I was able to confirm this issue by running on iPhone 5s. Unfortunatelly, you are pushing PaintCode, Xcode and iOS to their functional limits by trying to use drawing method with 53 thousand lines of code. This single method takes 9 MB in the binary (arm64 only, -Onone) and uses almost 1000 variables of pointer type. My best guess it that the app reaches some limits of stack memory size and is terminated by system.

We have seen StyleKits with more than 10 thousand lines before, but none of them had a single method this large. I would recommend to split your drawing into several canvases and compose them using Symbols, but I’m afraid that working with such huge drawing may be painfully slow.

Tricertops
  • 8,492
  • 1
  • 39
  • 41
  • Is there any other way then using PaintCode as I am not getting any other way. My project is having more than 50 maps like this. For now I am storing them as jpg file. But on zooming the image gets pixelated. I was trying to use svg image for this. Then I found PaintCode to be helpful. – PriyaJain Jul 28 '16 at 04:25
  • Is there something else that we can do with the image as splitting these many maps is I don't think is feasible. – PriyaJain Jul 28 '16 at 04:36
  • Is there a way to split the image using PaintCode? – PriyaJain Jul 28 '16 at 05:53
  • You can try using PDF and draw it using `CGPDFDocument`. That will preserve vector quality, but it may be slow. You may need some good tiling mechanism to draw only the visible parts, but I have no solution for that. – Tricertops Jul 28 '16 at 09:09
  • Ok. I will try that. Thanks a lot for all your support @Tricertops. – PriyaJain Jul 28 '16 at 09:24
  • useful info. I never think about the memory issue in drawRect method. – Teja Nandamuri Jul 28 '16 at 14:25
0

This happened to me recently, was caused by a mistyped file name on code of ViewController.swift.

eplazai
  • 306
  • 2
  • 9
0

Try putting @objc in front of the functions used, like so:

@objc func myFunction() {

More on objective C interoperability here: https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/InteractingWithObjective-CAPIs.html

ScottyBlades
  • 12,189
  • 5
  • 77
  • 85