Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12.2 Developer beta 2 Crash - initWithCoder error #69

Closed
SteynMarnus opened this issue Feb 15, 2019 · 11 comments
Closed

12.2 Developer beta 2 Crash - initWithCoder error #69

SteynMarnus opened this issue Feb 15, 2019 · 11 comments
Assignees
Labels

Comments

@SteynMarnus
Copy link

SteynMarnus commented Feb 15, 2019

Prerequisites

  • [X ] Put an X between the brackets on this line if you have done all of the following:
    • read our Wiki;
    • read the entire Known issues section;
    • checked that my issue isn't already filled;
    • searched StackOverflow's input-mask tag for similar problems.

Describe the bug

I noticed that after using ViewController that used a TextField utilising the input mask, the App would crash. This was strange since the that exact page worked the day before and I had not made any changes to that view controller or UI in storyboard - The only change I had made was in my enviroment: I had build the app with xCode 10 Beta 2 to be able to run/test the app on my iphone that is running the beta version of iOS 12.2 Developer beta 2. I decided to build out a new view controller by bringing over all the controlls from the current page one by one and seeing when it breaks - it only broke the moment I add the InputMask Delegate Objects.

Steps to reproduce the behaviour:

Have a page with a InputMask Textfield setup - build app for iOS 12.2 Developer beta 2 (using xCode 10 beta 2)

Expected behaviour
Input Mask functions

Actual behaviour
App crashes: error produced:
Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'

That is the core of the problem, however, the rest of the error call stack can be found here:

*** First throw call stack: ( 0 CoreFoundation 0x0000000108ca072b __exceptionPreprocess + 331 1 libobjc.A.dylib 0x000000010768eac5 objc_exception_throw + 48 2 CoreFoundation 0x0000000108ca0585 +[NSException raise:format:] + 197 3 UIFoundation 0x000000010f47e89c UINibDecoderDecodeObjectForValue + 827 4 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432 5 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 6 UIKitCore 0x0000000111825e90 -[UIViewController initWithCoder:] + 1021 7 DumaPay Consumer iOS 0x00000001055bde66 $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfc + 2214 8 DumaPay Consumer iOS 0x00000001055bdf2f $s20DumaPay_Consumer_iOS25TestAddCardViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47 9 UIKitCore 0x0000000111aaae89 -[UIClassSwapper initWithCoder:] + 246 10 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753 11 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 12 UIKitCore 0x0000000111aaf4d1 -[UIRuntimeConnection initWithCoder:] + 178 13 UIFoundation 0x000000010f47e852 UINibDecoderDecodeObjectForValue + 753 14 UIFoundation 0x000000010f47eaf9 UINibDecoderDecodeObjectForValue + 1432 15 UIFoundation 0x000000010f47e554 -[UINibDecoder decodeObjectForKey:] + 251 16 UIKitCore 0x0000000111aacd81 -[UINib instantiateWithOwner:options:] + 1216 17 UIKitCore 0x0000000111fc5290 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181 18 DumaPay Consumer iOS 0x0000000105623ea9 $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC010goToManualfE004cardG6ResultySo0b15CardsRecognizerN0CSg_tF + 249 19 DumaPay Consumer iOS 0x0000000105623d2e $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tF + 62 20 DumaPay Consumer iOS 0x0000000105623d8c $s20DumaPay_Consumer_iOS28AddCardScannerViewControllerC02oneF15ManuallyClicked6senderyyp_tFTo + 76 21 UIKitCore 0x0000000111e2e834 -[UIApplication sendAction:to:from:forEvent:] + 83 22 UIKitCore 0x00000001118845b5 -[UIControl sendAction:to:forEvent:] + 67 23 UIKitCore 0x00000001118848d2 -[UIControl _sendActionsForEvents:withEvent:] + 450 24 UIKitCore 0x0000000111883888 -[UIControl touchesEnded:withEvent:] + 583 25 UIKitCore 0x0000000111e6751e -[UIWindow _sendTouchesForEvent:] + 2547 26 UIKitCore 0x0000000111e68c02 -[UIWindow sendEvent:] + 4079 27 UIKitCore 0x0000000111e47346 -[UIApplication sendEvent:] + 356 28 UIKitCore 0x0000000111f178c3 __dispatchPreprocessedEventFromEventQueue + 3232 29 UIKitCore 0x0000000111f1a1e9 __handleEventQueueInternal + 5911 30 CoreFoundation 0x0000000108c07c11 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 31 CoreFoundation 0x0000000108c07493 __CFRunLoopDoSources0 + 243 32 CoreFoundation 0x0000000108c01b4f __CFRunLoopRun + 1231 33 CoreFoundation 0x0000000108c01332 CFRunLoopRunSpecific + 626 34 GraphicsServices 0x000000010f1222fe GSEventRunModal + 65 35 UIKitCore 0x0000000111e2d1d2 UIApplicationMain + 140 36 DumaPay Consumer iOS 0x0000000105609bdb main + 75 37 libdyld.dylib 0x000000010a883861 start + 1 38 ??? 0x0000000000000001 0x0 + 1 )

Platform information

  • OS version: iOS 12.2 beta 2
  • Library version: 4.1.0
  • Language: Swift 4.2
@taflanidi
Copy link
Collaborator

Hey @SteynMarnus,
Nice catch! Thanks a lot for all the debug information.

I tried running our Sample with the latest Xcode-beta, and I've got the same results as you.
I'll take a look into it, and I'll share the results of the investigation.

@SteynMarnus
Copy link
Author

Hey @SteynMarnus,
Nice catch! Thanks a lot for all the debug information.

I tried running our Sample with the latest Xcode-beta, and I've got the same results as you.
I'll take a look into it, and I'll share the results of the investigation.

No prob! Beta is a bit of 'wild-west'. Thank you for looking into it.

@taflanidi
Copy link
Collaborator

taflanidi commented Feb 15, 2019

Okay, somehow I've missed it.
Here, known issue no.2:

To reduce the size taken up by Swift metadata, convenience initializers defined in Swift now only allocate an object ahead of time if they’re calling a designated initializer defined in Objective-C. In most cases, this has no effect on your program, but if your convenience initializer is called from Objective-C, the initial allocation from +alloc is released without any initializer being called.

Basically, an alloc/init sequence dependency problem. Again…

Well, while this is being resolved, a workaround would be to replace

public override convenience init() {
    // Interface Builder support
    self.init(primaryFormat: "")
}

with

public override init() {
    // Interface Builder support
    self.primaryMaskFormat = ""
    self.autocomplete = true
    self.autocompleteOnFocus = true
    self.rightToLeft = false
    self.affineFormats = []
    self.affinityCalculationStrategy = .wholeString
    self.customNotations = []
    self.onMaskedTextChangedCallback = nil
    super.init()
}

Let's keep this open until the official Swift 5 release.

@SteynMarnus
Copy link
Author

Oh ok cool @taflanidi , will give this a go - I assume I have to replace this in the MaskedTextViewDelegate.swift file in the pod itself right?

@taflanidi
Copy link
Collaborator

taflanidi commented Feb 22, 2019

@SteynMarnus whatever suits you. Depending on your team size you may want to introduce your own fork or just replace those lines in the pod itself if you work on your own; you know better than me.

I don't want to put those changes into the library just yet. This workaround sounds code duplication, plus it's still a Swift 5 optimisation issue, so I think we'd better hold off.

UPD. I guess it's MaskedTextFieldDelegate you are using, not MaskedTextViewDelegate; nevertheless, both of them have the same issue.

@sashaBizquit
Copy link

Hey
Today Xcode 10.2 have been released and this bug is still in there.

@taflanidi your workaround doesn't help.

@Rik626
Copy link

Rik626 commented Mar 27, 2019

@sashaBizquit I found simply workaround

required public init?(coder aDecoder: NSCoder) {
   // Interface Builder support
   self.primaryMaskFormat = ""
   self.autocomplete = true
   self.autocompleteOnFocus = true
   self.rightToLeft = false
   self.affineFormats = []
   self.affinityCalculationStrategy = .wholeString
   self.customNotations = []
   self.onMaskedTextChangedCallback = nil
   super.init()
}
public override init() {
   // Interface Builder support
   self.primaryMaskFormat = ""
   self.autocomplete = true
   self.autocompleteOnFocus = true
   self.rightToLeft = false
   self.affineFormats = []
   self.affinityCalculationStrategy = .wholeString
   self.customNotations = []
   self.onMaskedTextChangedCallback = nil
   super.init()
}

Sometimes u may need to clean build after this replacement

@taflanidi
Copy link
Collaborator

Hey @sashaBizquit, hey @Rik626!
Thanks a lot for your reports.

The patch is coming later this week, please stay tuned.

@brenovaladao
Copy link

any update about this issue?

@MrPovilas
Copy link

Still no updates?

@taflanidi
Copy link
Collaborator

Okay, so there was yet an another Swift 5-related bug I had to additionally investigate in order to make sure everything's working, it took some time.

Meet v.4.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants