iOS Error

52 views
Skip to first unread message

CS

unread,
Jan 7, 2018, 3:41:11 AM1/7/18
to CodenameOne Discussions
If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans
Device: iPad Pro 9.7 
OS: iOS 10.1.1
I compile debug version.

Error Displayed on show form (Form is empty): "An internal application error occurred: java.io.IOException: Err"

This is a strange one. Only some small "unrelated" changes causes this, while Andorid builds work just fine under the same code.

E.g.:
This works
Label lTime = new Label("Time");
//lTime.setVerticalAlignment(CENTER); 

While this causes error
Label lTime = new Label("Time");
lTime.setVerticalAlignment(CENTER); 

This works
Label lTime = new Label("Time");
this.addComponent(3, lTime);
Container c1 = new Container(new BoxLayout(BoxLayout.X_AXIS));
//c1.add(lTime);
...
this.addComponent(4, c1);

while this causes error
Label lTime = new Label("Time");
//this.addComponent(3, lTime);
Container c1 = new Container(new BoxLayout(BoxLayout.X_AXIS));
c1.add(lTime);
...
this.addComponent(3, c1);

I could go on and on ... so something must be really ...

Best regards,
CS

Dave Dyer

unread,
Jan 7, 2018, 2:21:58 PM1/7/18
to CodenameOne Discussions
Is this running in the EDT thread?  If not try it. The GUI code is full
of places where running stuff in other threads can cause problems.

CS

unread,
Jan 8, 2018, 12:04:01 AM1/8/18
to CodenameOne Discussions
I do not think so (but correct me if I am wrong). But I have not had this problems (ever), in last two weeks I was doing some changes to "old" code and suddenly I have all these problems. Again only on iOS, Android works fine.

So I have a main form where I do:
        Button button = new Button("Open");
        button.addActionListener(e -> {
            NewForm gf = new NewForm(someparameter);
            gf.show();
        });

then in NewForm class
    public NewForm(someparameters) {
        this();
        this.init();
    }
   private void init() {
        //here I do all the setup regarding looks of this form and here the above shown problem "happens"
   }

Shai Almog

unread,
Jan 8, 2018, 12:15:05 AM1/8/18
to CodenameOne Discussions
You are getting an IOException and none of these pieces of code relate to IO so it's hard to pinpoint what you might be seeing. I'm guessing these things impact something that might have something to do with IO later on. If we had the stack trace this would help. You can try using try/catch to pinpoint the location of the error.

CS

unread,
Jan 10, 2018, 12:16:47 AM1/10/18
to CodenameOne Discussions
After some testing (putting try/catch on all logical and non-logical places) I narrowed it down to your bluethooth library. Just by placing try/catch "around" blocks where bluetooth is being used (actually created/initialized) the error went away. So it seems is something related to the library.

Since getStackTrace() function is not supported, could you tell me what is the nicest/easiest way to get you required stack trace?

Shai Almog

unread,
Jan 10, 2018, 12:34:39 AM1/10/18
to CodenameOne Discussions
There is crash protection in the pro level which I'm assuming you don't have.
Normally you can connect a cable and look at the logs to see what went wrong but that might not work well for iDevices without a Mac and due to recent changes from Apple might not work well for iDevices at all.

If you have a Mac you can also debug the project on xcode and see the output/exceptions https://www.codenameone.com/how-do-i---use-the-include-sources-feature-to-debug-the-native-code-on-iosandroid-etc.html

Finally you can try to isolate a standalone test case with no logic that still fails and file an issue. Since this is a recent regression it might relate to the Cordova support that the bluetooth code relies on. I know Steve made some changes to the JS library layer so maybe he has an idea.

Dave Dyer

unread,
Jan 10, 2018, 11:43:20 AM1/10/18
to CodenameOne Discussions
 
I use this code to capture the contents of a log file.  Its a bit obscure because it threads
a needle through the standard codename1 class "Log" to create a temporary log file.

class LogCapture extends Log
{    Log oldLog;
    StringWriter myWriter;
    LogCapture()
    { oldLog = Log.getInstance();
      install(this); 
    }
    protected Writer createWriter() throws IOException
    {    return(myWriter = new StringWriter());
    }
   
    public String dispose()
    {
        install(oldLog);
        return(myWriter.toString());
    }
}

then, this code can capture a stack trace as a string

    public static String getStackTrace(Throwable t)
    {
        LogCapture cap = new LogCapture();
        Log.e(t);
        return cap.dispose();   
    }

Once acquired as a string, you can display it, save it to a file,
email it to yourself, or post it to a server you control.


CS

unread,
Jan 11, 2018, 12:04:34 AM1/11/18
to CodenameOne Discussions
Thank you Dave. I have implemented your code to get stack trace, but now for some reason error is gone. Maybe Steve changed something, but I do not get the error. I removed some of try/catch-es etc. iOS is working on every build. So, if I stumble on error again, I will post stack trace here.

Regards,
CS
Reply all
Reply to author
Forward
0 new messages