Jump to content

NecoArc

Members
  • Content Count

    19
  • Joined

  • Last visited

Everything posted by NecoArc

  1. I have an FMX self-service application designed to run on kiosks/tablets with printers and scanners. The application already works on various device models by integrating with their respective AAR/JAR libraries provided by the manufacturers (extracting the .jar files and generating the JNI interface using java2op). This past month, I have been working on integrating two devices sent by a new manufacturer: the Mini Kiosk Model and the Plus Kiosk Model. According to the manufacturer, the same AAR and method calls are used for both devices. On the Mini Kiosk, I was able to make everything work without any issues. However, on the Plus Kiosk, which should work the same way, Delphi returns the following error: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.HashMap android.hardware.usb.UsbManager.getDeviceList()' on a null object reference. So i created a test project in Java that worked fine on both devices, the issue is not with the AAR itself. After talking to the manufacturer’s support, I was advised that the Plus Kiosk requires the startup-runtime-1.1.0 library (Startup Runtime initializes objects and components automatically when the application starts). I checked the manifest.xml inside the AAR and found the following declaration: <application> <provider android:name="androidx.startup.InitializationProvider" android:authorities="${applicationId}.androidx-startup" android:exported="false" tools:node="merge" > <meta-data android:name="com.e1.Comunicacao.ConUSB" android:value="androidx.startup" /> <meta-data android:name="com.e1.Pagamento.Brigde.ConfigFileInitializer" android:value="androidx.startup" /> </provider> </application> This explains the "null object reference" error, as the UsbManager class is not being initialized properly. However, as far as I understand, Delphi already includes this library internally. So I am looking for suggestions on how I can try to solve this issue: Is there a way to check if startup-runtime is correctly interacting with the manufacturer's libraries? Do I need to regenerate the JNI interface, adding startup-runtime to it? (I’m going to try this now, but I don’t see much sense in doing so.) Can someone please help me? I've already spent several days trying to understand and fix this error.
  2. yeah i notice that extra space after the print, i made some test without it and it keeps crashing the aplication from what i've understood putting any kind of provider tag on the manifest.template.xml just break the application so i took it out before finding a solution then we can conclude that the tag is not necessary but still in some other situation it may be necessary since my solution does not use the native startup runtime (but I don't know if it would be possible because simply adding the provider tag breaks the application) i tested with other types of tag and they were ok
  3. So after a lot of struggle, I finally managed to make this damn thing work. The real issue was the startup-runtime, and I still don’t know how to make it run automatically. I noticed that in the JNI I had, the classes that needed the startup-runtime were commented out, as if java2op hadn’t created their interfaces. To fix the problem, I took the startup-runtime-1.1.1.jar from Embarcadero’s folder and created a new JNI along with this .jar. Right away, I saw that the interfaces using startup-runtime were no longer commented. But that still wasn’t enough to make it work—I had to manually call the methods created by the startup-runtime in Delphi. In my case: jConfigInitializer := TJConfigFileInitializer.Create; usb := TJConUSB.Create; usb.create(TAndroidHelper.Context); and after that it worked
  4. nah it just crashes bro 😕 even if i only add the provider tag without the meta-data the aplication just close when starting
  5. Well now my application crashes instantly when I open it I think this is the right way
  6. thank you for the sugestion i need edit this one inside my aplication folder?
  7. NecoArc

    Memory leak on parsing json

    I have a simple function where i call a json file from memory and then parse it on a FMX project procedure TPrincipal.Button3Click(Sender: TObject); var jsonstr:string; json :TJsonObject ; begin jsonstr:=TFile.ReadAllText(ExtractFilePath(paramstr(0))+'\jsonTeste.json', TEncoding.UTF8); json :=TJSONObject.ParseJSONValue(jsonstr) as TJSONObject; freeandNil(json); end; the json is a 449kb file so it's n ot a big one but when i execute the TJSONObject.ParseJSONValue(jsonstr) as TJSONObject command the memory of my aplication goes up in 20mb then when i execute freeandNil(json) the memory do not goes down those 20mb continues to weigh throughout the execution of the application when i close it, it present memory leaks on jsonObjects, jsonStrings, unicodeString etc. but like why????? i don't understand what is wrong and this seems to happend only with this json thanks for any help, the json file is attached. jsonTeste.json
  8. NecoArc

    Memory leak on parsing json

    In my understanding, FASMM shouldn't cause an increase of 20mb either, but that's the best guess because when I remove the FASMM call from the .dpr of my project the situation stops happening. i attached the memory leak report AutoatendimentoRefatorado_MemoryManager_EventLog.zip
  9. NecoArc

    Memory leak on parsing json

    oh the irony, the lib used to find memory leaks is causing memory leaks
  10. NecoArc

    Memory leak on parsing json

    you helped me a lot bro, i created another project and realise the problem wasn't happening then, after some search i realise that it was because FASTMM4 is active on the project
  11. NecoArc

    Memory leak on parsing json

    oh I forgot to mention that it's an FMX project I don't know if the same happens with VCL
  12. NecoArc

    Memory leak on parsing json

    i'm also using delphi 12.2 did you use the same json file? notice that the memory goes up 20mb after parsing?
  13. I have a situation that occurs on low-end Android devices. Short version: When the user double-taps a button, the event is being executed on the button that hasn't been created on the screen yet. What happens is, I have a list of frames created on my screen, which represent the product categories. When I tap on a category frame, the application destroys the category frames on the screen and creates a new set of product frames. The problem is, when my user double-taps very quickly on the category frame, the second click is executed on the product frame that hasn't even appeared on the screen yet. I'm using delphi 12.2 My code is something like this: procedure CreateCategory; var frm: TFrameCategory; category: TObjCategory; begin for category in listCategory do begin frm := TFrameCategory.Create(nil, category); frm.OnClick := OnClickCategory; rectangleFrames.AddObject(frm); end; end; procedure OnClickCategory(Sender: TObject); var frm: TFrameProduct; prod: TObjProduct; i: Integer; begin for i := rectangleFrames.ControlsCount - 1 downto 0 do begin rectangleFrames.Controls.DisposeOf; end; rectangleFrames.ControlCollection.Clear; for prod in listProduct do begin frm := TFrameProduct.Create(nil, prod); frm.OnClick := OnClickProduct; rectangleFrames.AddObject(frm); end; end So, the second tap is executed in OnClickProduct instead of being executed twice in OnClickCategory. How can I prevent this? i've alredy tryed a lot of things like calling this procedure on the OnClickCategory event but it doesn't seems ideal procedure disableRecTemp; begin rectangleFrames.Enabled:= False; TThread.CreateAnonymousThread(procedure begin Sleep(1500); TThread.Synchronize(nil, procedure begin rectangleFrames.Enabled := True; end); end).Start; end
  14. I have a project that at some point I need to display many images on the screen at the same time These images are registered by the user, so before I didn't pay attention to the size of the images one of the users was registering 11MB png images which at some point caused the app to crash because the RAM consumption was going too high Then I did a treatment to resize the images and it worked fine... But I can't stop thinking, what if I want to use the images with the best possible resolution? even on devices with high performance, the RAM consumption is huge, eight 11MB images displayed on the screen at the same time use 500MB+ i have a loop that create frames and do something like: for product in menu do begin frame:= TFrmImageItem.create(product, 'imagePath'); layoutFrmImageItem.addObject(frame); end; constructor TFrmImageItem.create(product:TProduct, imagepath:string); var bitmap:TBitmap begin lbName.text:=product.name; bitmap := tbitmap.create; bitmap.setSize(TSize.create(200,200)); bitmap. LoadFromFile(imagePath); Timage.bitmap.assign(bitmap); bitmap.free; end i wonder what else can be done to reduce the memory consuption without resizing the images i've alredy implemented a virtualization method to set frameVisible:=false when the frame is not on the screen also a double buffer method (wich didn't work well) i wonder if you guys can provide me any ideas maybe the memory is skyrocketing because i'm using frames?
  15. thanks for the suggestions guys i'll see what i can do now (also this website is really annoying it was saying my IP was blocked because of spam but it's the first time i'm using this community )
  16. that code was just a small exemple i have a generic function that returns me a lot of diferent types of bitmaps depending on my object, but there was no point into showing everything also, you're right in point 1. i took off the bitmap.setsize and it made no difference at all i'll give a try on your suggestion
  17. thanks i'll give it try first time i've heard of this method
  18. NecoArc

    Listbox with images scrolls not smoothly

    i'm having the same problem and is so anoying, i have a vertscrollbox that i populate with frames the more frames i have the worst it gets one of the solutions i found was to set frame.visible:=false, when the frame is not showing on the scroll the second was setting the image on each frame to visible:=false while scrolling the second one brought a significative enhancement, but setting the image to visible false while scrolling is just dumb changing form.quality property didn't change too much options systemDefault and highQuality were basically the same while highPerformance make the scroll animation even worst i really don't understand why this is like this since the list view component can scroll smothly, but infortunelly i had to change it since it was using too much memory and was crashing the application in low performance devices i'll try to install alcione to see how it works using delphi 12.1
×