Jump to content

Yaron

Members
  • Content Count

    275
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Yaron


  1. I even created a simple load-testing app (https://github.com/bLightZP/Web-Server-Load-Tester) that opens the URL in multiple threads simultaneously (triggers the crashes instantly).

     

    With 10 thread it crashes instantly if there's DB access, if I disable the DB access code, even 1000 threads work just fine.

    And even with just 2 threads it can occasionally crash.


  2. Using Delphi 10.3.3 I built a simple web server using MARS Curiosity (https://en.delphipraxis.net/forum/34-mars-curiosity-rest-library/) and FireBird DB v3.0.4.

     

    However, sometimes a simple refresh in the web browser (Ctrl+R) will trigger multiple different errors:

    Project GameServicesServerApplication.exe raised exception class EIdSocketError with message 'Socket Error # 10053 Software caused connection abort.

    Project GameServicesServerApplication.exe raised exception class $C0000005 with message 'access violation at 0x00730647: read of address 0x00000000'.
    Project GameServicesServerApplication.exe raised exception class EDatabaseError with message 'Field 'CONSUMERNAME' not found'.

    Project GameServicesServerApplication.exe raised exception class EArgumentOutOfRangeException with message 'Argument out of range'.
     

    Holding Ctrl+R in the web browser easily reproduces the issue within a few seconds (the more DB calls I preform in the MARS web server function, the easier it is to trigger the crash).

    The fault is not in MARS, I tested by disabling all DB calls and verifying the code doesn't crash (I even threw a Sleep(1000) in there to see if it may be related to the duration it takes the function to process).

     

    Am I doing something wrong?

     

    I use a connection pool to support multiple threads connecting at once, here is how I connect to the DB:

      dbParams := TStringList.Create;
      try
        dbParams.Add('Server=localhost');
        dbParams.Add('Database=c:\DB\Database.FDB');
        dbParams.Add('User_Name=SYSDBA');
        dbParams.Add('Password=SomePassword');
        dbParams.Add('CharacterSet=UTF8');
        dbParams.Add('Pooled=True');
        FDManager.AddConnectionDef(dbPoolName,'FB',dbParams);
        Try
          FDManager.Open;
        Except
          on E : Exception do {$IFDEF TRACEDEBUG}AddDebugEntry(debugFileSystem,'Exception connecting to DB : '+E.Message){$ENDIF};
        End;
      finally
        dbParams.Free;
      end;

     

    Here's the MARS server definition:

    Type
      [Path('test')]
      TGalleryServicesResource = class
      protected
      public
        [GET , Path('/gallery'), Produces(TMediaType.TEXT_HTML)]
        function Gallery_From_External_Source([QueryParam] code : String) : String;
      end;

     

    Here is the function MARS triggers:

    function TGalleryServicesResource.Gallery_From_External_Source(code : String) : String;
    begin
      If GetGalleryCodeDetails(sDebugFile,code,nGalleryCode) = True then
      Begin
      End;
    end;

     

    And here is the database access:

    function  GetGalleryCodeDetails(sDebugFile,sGalleryCode : String; var nGalleryCode : TGalleryCodeRecord) : Boolean;
    var
      dbQuery : TFDQuery;
    begin
      Result := False;
      dbQuery := TFDQuery.Create(nil);
      Try
        dbQuery.ConnectionName := dbPoolName;
        dbQuery.SQL.Text := 'SELECT * FROM GALLERY_CODES WHERE CODE_UID=:gallerycodeuid;';
    
        Try
          dbQuery.Prepare;
          dbQuery.ParamByName('gallerycodeuid').AsString := sGalleryCode;
          dbQuery.Open;
          If dbQuery.RecordCount > 0 then
          Begin
            Result := True;
            With nGalleryCode do
            Begin
              gcUserName              := dbQuery.FieldByName('CONSUMERNAME').AsString;
              gcUserEMail             := dbQuery.FieldByName('CONSUMEREMAIL').AsString;
              gcCodeUID               := dbQuery.FieldByName('CODE_UID').AsString;
              gcImageURL              := dbQuery.FieldByName('IMAGEURL').AsString;
              gcCreateTimeStamp       := dbQuery.FieldByName('CREATE_TIMESTAMP').AsFloat;
              gcOpenTimeStamp         := dbQuery.FieldByName('OPEN_TIMESTAMP').AsFloat;
              gcUseTimeStamp          := dbQuery.FieldByName('USE_TIMESTAMP').AsFloat;
              gcStatus                := dbQuery.FieldByName('STATUS').AsInteger;
            End;
          End;
        Except
          on E : Exception do {$IFDEF TRACEDEBUG}AddDebugEntry(sDebugFile,'Exception : '+E.Message){$ENDIF};
        End;
      Finally
        dbQuery.Free;
      End;
    end;

     


  3. I was able to modify the style to me desire, called it "mytheme.vsf",

     

    When trying to apply it in the registry by setting "Theme" to "Custom" and "VCLStyle" to "mytheme.vsf" (after placing the file in "c:\Program Files (x86)\Embarcadero\Studio\20.0\Redist\styles\vcl\").

     

    However, Delphi doesn't seem to be using the style, what's more, after restoring the registry setting, if i look under the themes pop-up-menu (clicking the little window-moon icon), the "custom" entry is grayed out.


  4. 14 minutes ago, Dalija Prasnikar said:

    There are few problems here.

     

    First, IDE themes are slightly different from general VCL Styles so you cannot use them because some parts of IDE will not be painted properly. Next VCL Style editor is rather hard to use for creating any theme from scratch. 

     

    Your best option would be to extract theme resource from darktheme260.bpl (haven't checked if this is the right bpl, as I have customized light theme), and then use that resource as starting point for your customization. 

     

    IDE themes are copyrighted, so you should not distribute such hacked theme.

    What do I use to extract the resources and what do I use to them rebuilt the file and make it accessible in the IDE?

    Remember, I only need to change a few RGB values, not really anything too complex.

     

    I guess if I can't share my work, I'll just document which values I changed.


  5. I'm aware that with recent versions, the theming has been rewritten so I'm wondering if there's any tool/editor supporting the latest Delphi theming features that would let me specify my own RGB values for each UI element.

     

    I would like to create an alternative dark theme that's more utilitarian.

    While I prefer a dark theme for eye strain, I find the current dark theme too flat with UI elements that I expect to be on a different plane (color) becoming merged visually (e.g. Scrollbars widgets).

    I'm aware there are a few other dark'ish themes included, but they too suffer from their own issues so I would rather create (and share of course) my own color-theme.


  6. I figured out why it's crashing in my code and not in the simple sample page,

    If the HTML form file input has an "accept" field (e.g. "<input type="file" accept=".jpg, .jpeg" name="UploadImage" required>"), the App will crash.

     

    Since I may not have control over the form's design, I am still looking for a solution around this issue.

     

    You can easily test this with the code I linked in the previous post by replacing:

      WebBrowser.Navigate('https://ps.uci.edu/~franklin/doc/file_upload.html');

    With:

      WebBrowser.LoadFromStrings(
      '<HTML><HEAD><TITLE>Test</TITLE></HEAD><BODY>'+
      '<form method="post" enctype="multipart/form-data" action="https://bla.com">'+
      '<input type="file" accept=".jpg, .jpeg" name="UploadImage" required>'+
      '<input type="submit" value="Save">'+
      '</form>'+
      '</BODY></HTML>','');

     

    • Like 1

  7. I also tried recreating the FManager component after each page load like this:
     

    procedure TMainForm.WebBrowserDidFinishLoad(ASender: TObject);
    begin
      FManager := nil;
        {$IFDEF TRACEDEBUG}AddDebugEntry('Create FWebManager (before)');{$ENDIF}
        Try
          FManager := TWebChromeClientManager.Create(WebBrowser);
        Except
          on E: Exception do
          begin
            {$IFDEF TRACEDEBUG}AddDebugEntry('Error creating FWebManager : '+E.Message);{$ENDIF}
          end;
        End;
        {$IFDEF TRACEDEBUG}AddDebugEntry('Create FWebManager (after)');{$ENDIF}
    end;
    

    But it didn't help, still crashes instantly after pressing the button.


  8. 14 hours ago, Dave Nottage said:

    It seems that setting the WebChromeClient works only when the TWebBrowser is visible. Move your code that creates FWebManager to just after you set VoucherimWebBrowser.Visible to True.

    Sadly, this issue is not resolved.

    Like you wrote, it only works if the TWebBrowser component is visible and I verified that it works using the very simple upload form you linked to originally.

    However, when using it in a more complicated form, after browsing through several pages within the WebView to reach the form, clicking the button just terminates the App instantly (no UI error message).

    Looking at the logcat, here's the output:

     

    11-28 12:44:35.138  3138  3240 I InputDispatcher: Delivering touch to (3807): action: 0x0, toolType: 1
    11-28 12:44:35.138  3807  3807 D ViewRootImpl: ViewPostImeInputStage processPointer 0
    11-28 12:44:35.208  3138  3241 D InputReader: Input event(9): value=0 when=3853093882434000
    11-28 12:44:35.208  3138  3241 D InputReader: Input event(9): value=0 when=3853093882434000
    11-28 12:44:35.208  3138  3241 I InputReader: Touch event's action is 0x1 (deviceType=0) [pCnt=1, s=] when=3853093882434000
    11-28 12:44:35.208  3138  3240 I InputDispatcher: Delivering touch to (3807): action: 0x1, toolType: 1
    11-28 12:44:35.208  3807  3807 D ViewRootImpl: ViewPostImeInputStage processPointer 1
    11-28 12:44:35.238  3807  3807 D Instrumentation: checkStartActivityResult() : Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.jpg }
    11-28 12:44:35.238  3807  3807 D Instrumentation: checkStartActivityResult() : intent is instance of [Intent].
    11-28 12:44:35.238  3138  4840 D ApplicationPolicy: isIntentDisabled start :Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.jpg }
    11-28 12:44:35.238  3138  4840 D ApplicationPolicy: isIntentDisabled return :false
    11-28 12:44:35.238  3807  3807 W System.err: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.GET_CONTENT cat=[android.intent.category.OPENABLE] typ=.jpg }
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1878)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.app.Instrumentation.execStartActivity(Instrumentation.java:1545)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.app.Activity.startActivityForResult(Activity.java:4283)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.app.Activity.startActivityForResult(Activity.java:4230)
    11-28 12:44:35.238  3807  3807 W System.err: 	at com.embarcadero.rtl.ProxyInterface.dispatchToNative(Native Method)
    11-28 12:44:35.238  3807  3807 W System.err: 	at com.embarcadero.rtl.ProxyInterface.invoke(ProxyInterface.java:21)
    11-28 12:44:35.238  3807  3807 W System.err: 	at java.lang.reflect.Proxy.invoke(Proxy.java:393)
    11-28 12:44:35.238  3807  3807 W System.err: 	at $Proxy12.onFileChooserIntent(Unknown Source)
    11-28 12:44:35.238  3807  3807 W System.err: 	at com.delphiworlds.kastri.DWWebChromeClient.onShowFileChooser(DWWebChromeClient.java:29)
    11-28 12:44:35.238  3807  3807 W System.err: 	at N6.a(PG:145)
    11-28 12:44:35.238  3807  3807 W System.err: 	at xp.runFileChooser(PG:2)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.os.MessageQueue.nativePollOnce(Native Method)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.os.MessageQueue.next(MessageQueue.java:323)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.os.Looper.loop(Looper.java:143)
    11-28 12:44:35.238  3807  3807 W System.err: 	at android.app.ActivityThread.main(ActivityThread.java:7225)
    11-28 12:44:35.238  3807  3807 W System.err: 	at java.lang.reflect.Method.invoke(Native Method)
    11-28 12:44:35.238  3807  3807 W System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
    11-28 12:44:35.238  3807  3807 W System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
    11-28 12:44:35.248  1343  1516 D libEGL  : eglTerminate EGLDisplay = 0xb690164c
    11-28 12:44:35.258  1343  4318 I SurfaceFlinger: id=17304 Removed TurfaceView (4/10)
    11-28 12:44:35.258  1343  1522 I SurfaceFlinger: id=17304 Removed TurfaceView (-2/10)
    11-28 12:44:35.268  1343  1343 D libEGL  : eglTerminate EGLDisplay = 0xbe93d3ac
    11-28 12:44:35.888  3138  3240 W InputDispatcher: channel ~ Consumer closed input channel or an error occurred.  events=0x9
    11-28 12:44:35.888  3138  3240 E InputDispatcher: channel ~ Channel is unrecoverably broken and will be disposed!
    11-28 12:44:35.888  3138  4840 I WindowState: WIN DEATH: Window{891996c u0 d0 PopupWindow:8f2b053}
    11-28 12:44:35.898  3138  3914 D GraphicsStats: Buffer count: 11
    11-28 12:44:35.898  1343  1522 I SurfaceFlinger: id=17305 Removed QopupWindow (5/9)
    11-28 12:44:35.898  1343 19954 D libEGL  : eglTerminate EGLDisplay = 0xb09a86fc
    11-28 12:44:35.898  1343  1522 I SurfaceFlinger: id=17305 Removed QopupWindow (-2/9)
    11-28 12:44:35.898  1343 19954 D libEGL  : eglTerminate EGLDisplay = 0xb09a86fc
    11-28 12:44:35.898  3138  3920 I ActivityManager: Process com.inmatrix.Voucherim (pid 3807)(adj 0) has died(274,734)
    11-28 12:44:35.898  3138  3920 D ActivityManager: cleanUpApplicationRecord -- 3807

     


  9. Thanks Eli, Adding the library resolved the exception, however clicking on the choose file button still does nothing, so something else is preventing this from working in my own code and I can't seem to find out what.

     

    I posted the App's source here:

    https://inmatrix.com/temp/TestApp_src.zip

     

    It just wraps around a website, simply run it and click 'connect' (no need for name and pass, it just opens a sample file submission page)


  10. 17 minutes ago, Lars Fosdal said:

    You have to manually delete the overriding values that you put in earlier.

    For version info - you need to change the values to match "all config".
    After that, the debug/release version will follow the "all config" values.

    I tried that, it didn't work.

    Perhaps I didn't understand what you mean by "manually delete", I just used the project dialog to make sure all entries across debug/release/all configuration were the same and then changed the value on 'all configurations' to see if it affects the 'release configuration' (which it didn't).


  11. For some reason, any data I entered under the Project Options version info's "all configuration" entries is not actually applied to the release/debug sections.

     

    And later on, I couldn't upload to the play store, because it was seeing the old version number from the "release" section.

     

    Is it just me, or am I misunderstanding what the "all configuration" entries actually do (I was assuming it was applying whatever I entered into both release/debug profiles so I don't have to do everything twice).


  12. On 11/25/2019 at 1:04 PM, Dave Nottage said:

    I've managed to come up with something without having to patch FMX.WebBrowser.Android, but it still required Java code. I've put a demo here:

     

      https://github.com/DelphiWorlds/KastriFree/tree/master/Demos/WebBrowserFileChooser

     

    Note that it relies on other units in the Kastri Free project:

     

      https://github.com/DelphiWorlds/KastriFree

     

    ..including the compiled .jar, so you might want to just clone the repo and load the demo from it.

     

    The demo project seems to work, but when porting the snippet into my own code I'm catching an exception when calling "FWebManager := TWebChromeClientManager.Create(VoucherimWebBrowser);" :

    "Error creating FWebManager : java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.ClassLoader java.lang.Class.getClassLoader()' on a null object reference"

     

    Other than renaming the variables/components, I used the exact same OnCreate override as in the sample and just added an "FWebManager := nil" when closing the app.

    You mentioned including the jar file, but I haven't seen anything in particular in the demo itself, so I'm assuming it's included by one of the units (which I also included in my project).

     

    Any ideas?  If needed, I can post the entire source code for this app, it's just a wrapper around a web site.

     

    Unrelated, I get a hint while compiling:

    [DCC Hint] DW.WebChromeClient.Android.pas(98): H2443 Inline function 'TAndroidHelper.GetJActivity' has not been expanded because unit 'Androidapi.JNI.App' is not specified in USES list

     

    • Like 1

  13. Just for reference, my current logic is to resize the UI after an OnIdle event but not before an "TApplicationEvent.BecameActive" event triggers first.

    Seems to work, but I'm not perfectly confident that it works across every device.

     

    Oh, you may also notice something odd with the last resize event, the form's WindowState value was changed to "TWindowState.wsMinimized" even though the app is fullscreen.

    Perhaps this has something to do with the app being run on a phone with a notch.

×