iink SDK on Device

Answered

Not all strokes will be converted

I have a problem with the conversion, all strokes will be converted, but the handwritten stroke will not disappear. This problem appears very spontaneously. I cannot explain, when or how it occurs. Here is a picture 


image

And when the conversion does end, as you can see the last digit does not disappear. 

image

I have a link to a short clip so that you can see the mistake better: https://www.dropbox.com/s/vjuaz06gm4rqceg/testclip.mov?dl=0. 

Hopefully you can see my mistake. 


Best Answer

Dear Thanh,


Currently, on our side we were not able to reproduce unless when enabling math.convert.animate.


In order to investigate further, we have few questions: 

-Did you start your implementation straight with the 1.4.1 release of the iink?

-Or you started your developments with the iink 1.3 and updated to the 1.4.1? If so, as we did some changes in the "Rendering API", are you still using the former API of the 1.3, or are you using the API of the 1.4 (an easy way to know is if you are using the ICanvas2 and IRenderTarget2 interfaces, that have been added in teh 1.4 release)?


Thank you,


Best regards,


Olivier


Dear Thanh,


Thank you for the update.


On our side, the only way we could reproduce is setting the "math.convert.animate" configuration to true, otherwise, we were not able to.


On your side, do you enable it?


Best regards,


Olivier



Hello Olivier, 

I did not enable math.convert.animate configuration to yes. This problem only appears, as explained above, when the height constraint of the editorViewController was adjustable.

Best regards, 

Thanh 

Answer

Dear Thanh,


Currently, on our side we were not able to reproduce unless when enabling math.convert.animate.


In order to investigate further, we have few questions: 

-Did you start your implementation straight with the 1.4.1 release of the iink?

-Or you started your developments with the iink 1.3 and updated to the 1.4.1? If so, as we did some changes in the "Rendering API", are you still using the former API of the 1.3, or are you using the API of the 1.4 (an easy way to know is if you are using the ICanvas2 and IRenderTarget2 interfaces, that have been added in teh 1.4 release)?


Thank you,


Best regards,


Olivier

Dear Thanh Hoang,

thank you for contacting us.

Currently, similar behavior was occuring in the former releases of the iink SDK. This behavior has normally been solved in the latest 1.4 release of the iink SDK.

Can you confirm you are using the iink SDK 1.4?

Best regards,

Olivier

Hello Oliver, 

thanks for your fast reply. I just checked the podfile.lock and it says I use the 1.4.1 version. Here is a screenshot of my podfile.lock. Is this correct ? 

image

Dear Thanh,


thank you for the precision.


Currently, I was not able to reproduce on my side. Is it possible to have the configuration of your engine and editor: https://developer.myscript.com/docs/interactive-ink/1.4/reference/configuration/#math


I guess math.solver.enable is set to false? Can I have the full list? Also, how do you proceed to convert? You trigger a timer after penUP? Is it possible to have this code?


Thank you,


Best regards,


Olivier

Of course, here are the configurations: 

 if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
            if (appDelegate.engine == nil)
            {
                let alert = UIAlertController(title: "Certificate error",
                                              message: appDelegate.engineErrorMessage,
                                              preferredStyle: UIAlertController.Style.alert)
                alert.addAction(UIAlertAction(title: "OK",
                                              style: UIAlertAction.Style.default,
                                              handler: {(action: UIAlertAction) -> Void in
                                                exit(1)
                }))
                self.present(alert, animated: true, completion: nil)
                return
            }
            
            editorViewController.engine = appDelegate.engine
           
            
            do {
             try editorViewController.engine.configuration.setBoolean(false, forKey: "math.solver.enable")
            } catch {
                print("math config was not succesfull")
            }
            
            do {
             try editorViewController.engine.configuration.setBoolean(true, forKey: "math.eraser.show")
            } catch {
                print("math config was not succesfull")
            }

        }

 func createPackage(packageName: String) throws -> IINKContentPackage? {
        // Create a new content package with name
        var resultPackage: IINKContentPackage?
        
        let fullPath = FileManager.default.pathForFile(inDocumentDirectory: packageName) + ".iink"
        if let engine = (UIApplication.shared.delegate as? AppDelegate)?.engine {
            resultPackage = try engine.createPackage(fullPath.decomposedStringWithCanonicalMapping)
            // Add a blank page type Text Document
            if let part = try resultPackage?.createPart("Math") /* Options are : "Diagram", "Drawing", "Math", "Raw Content", "Text Document", "Text" */ {
                self.title = "Type: " + part.type

            }
        }
        return resultPackage
    }

And here is the timer: 

 

 private var timer: Timer?
    private var convertRequired: Bool = false
    private var countDown: Double = 1.5
    var latexString: String?
    private var packageName = "Next"

    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        if let touchFirst = touches.first {
            if touchFirst.location(in: editorViewController.view).y > 0 {
                containerView.writeHereLabel.isHidden = true
                if let time = timer {
                    time.invalidate()
                    timer = nil
                }
                convertRequired = true
            }
        }
    }

    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        if let touchFirst = touches.first {
            if touchFirst.location(in: editorViewController.view).y > 0 {

                timer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { timer in
                    self.countDown -= 0.5
                    if self.countDown == 0 && self.convertRequired == true  {
                        self.convertButtonWasTouched(nil)
                        self.countDown = 1.5
                        self.convertRequired = false
                        timer.invalidate()
                    }
                }
            }
        }
    }

 But this problem sometimes appears even if I convert manually by tapping a button and not using a timer. 

 

Update: It seems this error only appears if the View in which the EditorViewController is embedded is draggable, i.e. if the height constraint is adjustable. So I put the editorViewController in a container view with fixed constraints. I tried for about 30 minutes and I was not able to reproduce this error. I do not know why but it this error shows up if the height is adjustable. 

Thanks!