Recent

Author Topic: A LAMW Bug?  (Read 6335 times)

jmpessoa

  • Hero Member
  • *****
  • Posts: 1477
Re: A LAMW Bug?
« Reply #15 on: March 18, 2018, 07:24:59 pm »

In windows, if you try recompile/reinstall any LAMW package,  when a "LAMW" cross-project is open in IDE...  you can damage the IDE ....  so it is recommended that you perform these tasks first by opening a native windows project...
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #16 on: March 18, 2018, 07:31:51 pm »
Thank you. After several testings, I'm sure it is a bug how Lazarus handling package installation. I managed to solved the issue and reproduce it,  it seems to be something to do with the config files. I need more tests and will report back what I found. Maybe tomorrow, it's midnight here in my country.

Thaddy

  • Hero Member
  • *****
  • Posts: 9279
Re: A LAMW Bug?
« Reply #17 on: March 18, 2018, 07:47:49 pm »
That's not a Lazarus bug, but an LAMW bug. LAMW should conform to the way Lazarus handles package installation: decent proxies (separate design for real code) , do not touch config files unless necessary and tested, Use {$if defined(LAMW)} or something to prevent accidents like this.
« Last Edit: March 18, 2018, 07:52:42 pm by Thaddy »
also related to equus asinus.

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #18 on: March 18, 2018, 07:55:32 pm »
Please don't draw conclusion too early. Still need more testings. Be patient please.

Thaddy

  • Hero Member
  • *****
  • Posts: 9279
Re: A LAMW Bug?
« Reply #19 on: March 18, 2018, 09:04:08 pm »
I did actually test. Hence my conclusions. It is the way LAMW works which is atm. incompatible.
I did no extensive tests so miles may very, but the issues I mentioned are there. Note when compiling the code from the command line everything works fine if the paths are correct.
« Last Edit: March 18, 2018, 09:06:16 pm by Thaddy »
also related to equus asinus.

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #20 on: March 19, 2018, 05:33:55 pm »
Finally, I found the file and the exact line that causes the issue. It is in JNIAndroidProject.ini on the line of CanUpdateJavaTemplate=f

My LAMW worked but until it upgraded to revision 696, it got "List index out of bounds" error if I try to compile any of my LAMW projects. I tried to fix it by upgrading/downgrading to higher/lower revisions manually and OPM, and rebuilding the IDE. None of them can bring back my LAMW to work.

I had never manually edit the JNIAndroidProject.ini before, but I noticed the contents are very different if I delete the file and let LAMW to regenerate it. I keep a backup of the problem ini file. You can see img1 for the comparison.

After many tests, I found that it will work again if I simply delete the line:
CanUpdateJavaTemplate=f

img1.png is the comparison of the problem and 'regenerated' ini files using Meld. The left one is my original JNIAndroidProject.ini, which is problematic. The right one is the regenerated by LAMW.

img2.png is my settings for LAMW. For you information:
/home/handoko/Android/sdk is a link to /home/handoko/Android/android-sdk-linux
/home/handoko/Android/ndk is a link to /home/handoko/Android/android-ndk-r11c

JNIAndroidProject.ini.zip is the config file that causes the error, if anyone interested to test.
« Last Edit: March 19, 2018, 07:48:32 pm by Handoko »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1477
Re: A LAMW Bug?
« Reply #21 on: March 20, 2018, 04:37:01 am »
Quote
After many tests, I found that it will work again if I simply delete the line:
CanUpdateJavaTemplate=f

Thank you!!

NOTE: After removed,   "Can Update Java Template" will be always true (default) !!!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #22 on: March 20, 2018, 10:03:40 am »
Thank you. Using DispatchTouchDown/Move/Up really can solve the crash issue but it also introduces new issue. Tested on LAMW revision 700 on Android 7.1.2 phone.

Below is the code I used for testing, which also provided in the attachements:
Code: Pascal  [Select]
  1. {Hint: save all files to location: /home/handoko/Desktop/MicroWorld/jni }
  2. unit unit1;
  3.  
  4. {$mode delphi}
  5.  
  6. interface
  7.  
  8. uses
  9.   Classes, SysUtils, AndroidWidget, Laz_And_Controls, Laz_And_GLESv2_Canvas,
  10.   Laz_And_GLESv2_Canvas_h;
  11.  
  12. type
  13.  
  14.   { TAndroidModule1 }
  15.  
  16.   TAndroidModule1 = class(jForm)
  17.     jButton1: jButton;
  18.     jCanvasES2_1: jCanvasES2;
  19.     jTextView1: jTextView;
  20.     jTimer1: jTimer;
  21.     procedure AndroidModule1Close(Sender: TObject);
  22.     procedure AndroidModule1JNIPrompt(Sender: TObject);
  23.     procedure jButton1Click(Sender: TObject);
  24.     procedure jCanvasES2_1GLDown(Sender: TObject; Touch: TMouch);
  25.     procedure jCanvasES2_1GLDraw(Sender: TObject);
  26.     procedure jTimer1Timer(Sender: TObject);
  27.   private
  28.     var
  29.       grScaleX, grScaleY: Single; // Used internally for my graphics engine
  30.     procedure grCalculateScaleValues;
  31.     procedure ShowInfo;
  32.   end;
  33.  
  34. var
  35.   AndroidModule1 : TAndroidModule1;
  36.   TouchCount     : Integer = 0;
  37.  
  38. implementation
  39.  
  40. {$R *.lfm}
  41.  
  42. { TAndroidModule1 }
  43.  
  44. procedure TAndroidModule1.AndroidModule1Close(Sender: TObject);
  45. begin
  46.   jTimer1.Enabled := False;
  47. end;
  48.  
  49. procedure TAndroidModule1.AndroidModule1JNIPrompt(Sender: TObject);
  50. begin
  51.   jCanvasES2_1.DispatchTouchDown(False);
  52.   jCanvasES2_1.DispatchTouchMove(False);
  53.   jCanvasES2_1.DispatchTouchUp(False);
  54. end;
  55.  
  56. procedure TAndroidModule1.jButton1Click(Sender: TObject);
  57. begin
  58.   jTimer1.Enabled := not(jTimer1.Enabled);
  59.   ShowInfo;
  60. end;
  61.  
  62. procedure TAndroidModule1.jCanvasES2_1GLDown(Sender: TObject; Touch: TMouch);
  63. begin
  64.   Inc(TouchCount);
  65.   ShowInfo;
  66. end;
  67.  
  68. procedure TAndroidModule1.jCanvasES2_1GLDraw(Sender: TObject);
  69. begin
  70.   jCanvasES2_1.Screen_Setup (jCanvasES2_1.Width, jCanvasES2_1.Height, xp2D,cCull_YES);
  71.   jCanvasES2_1.Screen_Clear(1,1,1,1);
  72.   grCalculateScaleValues;
  73. end;
  74.  
  75. procedure TAndroidModule1.jTimer1Timer(Sender: TObject);
  76. begin
  77.   jCanvasES2_1.Refresh;
  78. end;
  79.  
  80. procedure TAndroidModule1.grCalculateScaleValues;
  81. begin
  82.   if (jCanvasES2_1.Height = 0) then Exit;
  83.   grScaleX := jCanvasES2_1.Width/jCanvasES2_1.Height;
  84.   grScaleX := 1;
  85. end;
  86.  
  87. procedure TAndroidModule1.ShowInfo;
  88. var
  89.   S: string;
  90. begin
  91.   case jTimer1.Enabled of
  92.     True:  S := 'Timer is on.';
  93.     False: S := 'Timer is off.';
  94.   end;
  95.   jTextView1.Text := S + LineEnding + 'TouchCount = ' + TouchCount.ToString;
  96. end;
  97.  
  98. end.

If I disable line #51..#53, the app will crash if I touch the white box (see image below) multiple times repeatedly rapidly. The crash won't be happen if the Timer is off.

If those lines are enabled, the crash issue is gone but the TouchCount in jCanvasES2_1GLDown won't be increased, see line #64.

The image on the left side is the screenshot when those lines are enabled, the TouchCount always stays zero.
« Last Edit: March 20, 2018, 10:09:44 am by Handoko »

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #23 on: March 20, 2018, 10:07:11 am »
You can download this apk for testing. This one is without using DispatchTouch.

Handoko

  • Hero Member
  • *****
  • Posts: 3231
  • My goal: build my own game engine using Lazarus
Re: A LAMW Bug?
« Reply #24 on: March 20, 2018, 10:08:37 am »
And this one is the apk using DispatchTouch.

Sorry I have to separate the attachments, due to the size limitation per post.