#1 2018-06-24 18:11:35

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Android Apps fail to start with the latest trunks

Alf,

With latest trunk for FPC  + mORMot + LAMW  all mORMot apps are terminated at startup:

ESynException: Unregistered ptCustom for TJSONRecordTextDefinition.AddItem(Line: TINTEGERDYNARRAY)

To reproduce:

1. Create a new App with LAMW ( ARMV7A + VFPv3)
2. Add  to  uses : SynCommons, mORMot, mORMotHttpClient
3. Run the app
4. Dump with Logcat to see the error

Last edited by Leslie7 (2018-06-25 13:21:51)

Offline

#2 2018-06-24 18:25:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Android Apps fail to start with the latest trunks

On which line does TJSONRecordTextDefinition crash?
I mean, parsing which record type?

Offline

#3 2018-06-24 18:43:14

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

I can only see this in the logcat dump:

E/libcontrols.so( 7235): ESynException: Unregistered ptCustom for TJSONRecordTextDefinition.AddItem(Line: TINTEGERDYNARRAY)

Even a freshly created LAMW GUI project with the  3  mentioned units added to uses  terminates with the same error.

Last edited by Leslie7 (2018-06-24 18:43:53)

Offline

#4 2018-06-24 19:16:58

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

I have installed NewPascal with fpcupdeluxe but the problem is the same.

Offline

#5 2018-06-24 21:30:43

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

This is probably not a new issue, I have pulled a version from 2018.01 and it does not work either.

Last edited by Leslie7 (2018-06-24 21:44:30)

Offline

#6 2018-06-25 06:31:59

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

This is really strange. After pulling an older version for  FPC, Lazarus, LAMW, mORMot from a date when it worked for me, the problem remains the same.

Offline

#7 2018-06-25 06:44:48

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

I have no idea  which component (Fpc, ...)  causes the issue, but after travelling back in time to 2017.08 it finally works.
I will try to pinpoint at what point it goes wrong.

Offline

#8 2018-06-25 07:09:06

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

With latest FPC, mORMot, LAMW, I experience exactly the same error !!

Edit:
With latest FPC, mORMot, LAMW, on arm linux (RPI3) , all goes well !!
So, no alignment issue as it seems.

Last edited by AOG (2018-06-25 09:47:42)

Offline

#9 2018-06-25 10:45:23

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

AOG,

is the problem solved or it just does not appear on an other machine?

Offline

#10 2018-06-25 11:50:58

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

Unfortunately on Windows 7  with the latest trunks the problem remains.

But the good news is that I have located the mORMot commit which introduced the problem.
It is probably a compiler issue in the first place, but maybe the changes committed here can be made more friendly to the current FPC trunk and help to create a well pointed bug report for the FPC team.

Revision: c5ad9b1d1f57177a8fe686271370cb12fc29d3d9
Author: Arnaud Bouchez <fakeaddress@synopse.info>
Date: 2018.02.01. 13:34:44
Message:
low-level refactoring, mainly for 64-bit FPC performance


----
Modified: SynCommons.pas
Modified: SynMongoDB.pas
Modified: SynopseCommit.inc

Offline

#11 2018-06-25 11:51:32

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

Still debugging. But perhaps Ab can help at this stage !

This function (inside TJSONCustomParserRTTI.CreateFromTypeName):
ndx := GlobalJSONCustomParsers.RecordSearch(aCustomRecordTypeName);

For a TINTEGERDYNARRAY, ndx is -1 !
So, the whole function (CreateFromTypeName) returns nil !!

Edit:
Just saw the new post. Perhaps the reports are related !?

Last edited by AOG (2018-06-25 11:57:49)

Offline

#12 2018-06-25 12:02:42

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

AOG,

Seems you are  close. smile

I am curious, how do you debug an android app?

Is there a way to prevent android  from terminating the the app when there is an issue? With the usual Try Except  many times it is stopped before reaching the exception handling part.

Last edited by Leslie7 (2018-06-25 12:11:39)

Offline

#13 2018-06-25 12:10:23

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

The (very) hard way ... ;-)
E.g.:
    ndx := GlobalJSONCustomParsers.RecordSearch(aCustomRecordTypeName);
    __android_log_write(ANDROID_LOG_DEBUG,'mORMot CreateFromTypeName ndx: ',PChar(InttoString(ndx)));

So, adding lines that are visible in ADB.

Normally, I make a custom ShowError function that directs this inserted debug-info to a place where I can easily study it.
Than, I am able to easily compare CPU-OS systems. So, I compare expected output on working systems with non-working systems.
As I said, the hard way ... especially on Android !

Offline

#14 2018-06-25 12:17:42

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

Well, that was the only way I could find as well.  Very time consuming. sad

I have seen somewhere (maybe in the Lazarus or NewPascal commits ) that there is an effort which seems to be aiming at  debugging IOS apps.
Do you see  a possible way to do the same for Android?

You have probably missed this later addition to my previous post:
Is there a way to prevent android  from terminating the the app when there is an issue? With the usual Try Except  many times it is stopped before reaching the exception handling part.

Last edited by Leslie7 (2018-06-25 12:34:58)

Offline

#15 2018-06-25 12:55:17

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

Is there  way to have Android  include a stack trace with the  names of the Pascal calls into the crash report? That would be very useful as well.

Offline

#16 2018-06-25 12:55:50

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

First part of problem found: IdemPropNameUSameLen
Thanks to your research !

If reverted, first part of my Android app works again !

Is there a way to prevent android  from terminating the the app

Nope. Android 8 is even worse: no permission = failure without warning.

Offline

#17 2018-06-25 15:54:19

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

Excellent!
Can you give me  what to change in the code to get it working?

Offline

#18 2018-06-25 15:59:31

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

Just replace the code inside the function with this code (the old code):

function IdemPropNameUSameLen(P1,P2: PUTF8Char; P1P2Len: PtrInt): boolean;
{$ifdef PUREPASCAL}
var i,j: integer;
begin
  result := false;
  j := 0;
  for i := 1 to P1P2Len shr 2 do
    if (PCardinal(PtrInt(P1)+j)^ xor PCardinal(@P2[j])^) and $dfdfdfdf<>0 then
      exit else
      inc(j,4);
  for i := j to P1P2Len-1 do
    if (PByteArray(P1)^[i] xor ord(P2[i])) and $df<>0 then
      exit;
  result := true;
end;

Works for me 100%. I hope also for you !

Offline

#19 2018-06-25 16:10:47

Leslie7
Member
Registered: 2015-06-25
Posts: 248

Re: Android Apps fail to start with the latest trunks

Yes it does! smile Thank you!

Offline

#20 2018-06-25 18:56:08

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Android Apps fail to start with the latest trunks

Please try https://synopse.info/fossil/info/5068ddbe77

I don't understand what was wrong with the previous code....

Offline

#21 2018-06-26 17:03:53

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

Hi Ab,

Your new code does not work either.
But the good news is ... I found out whats wrong : its a compiler error !

The inlining of this function does not work on Android.
If inlining is disabled, both the old code (from yesterday) as well as the new code works.

Strange aspect: the really old code (see post above, from 4 month go) does work with inlining ?!

Offline

#22 2018-06-26 17:44:00

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,242
Website

Re: Android Apps fail to start with the latest trunks

Yes, really strange! sad

I hope https://synopse.info/fossil/info/1c8350e285 will work better to circumvent the problem...

Offline

#23 2018-06-26 18:00:08

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Android Apps fail to start with the latest trunks

Your latest commit works out-of-the-box on Android.
Thanks !

Offline

Board footer

Powered by FluxBB