Jump to content

Yaron

Members
  • Content Count

    286
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Yaron

  1. I don't care about wasting resources while there's screen updates to generate, I'm concerned about wasting resources when doing nothing but waiting for the next update. Trying to work with v-sync is a pain, if you miss an update window there's serious judder.
  2. I found a good resource at https://github.com/grijjy/DelphiTimerQueue Hopefully it will resolve my issue, the workaround I'm currently using is having multiple thread that keep trying to update the screen if at least 1ms passed since another thread triggered an update. Not really the best approach.
  3. I don't want to block for v-sync, I don't care if there's tearing. I just want to get 60+fps screen updates without bogging down a CPU core. I'm looking at queue timers as FPiette mentioned (looks like multimedia timers were depreciated in favor of queue timers), if anyone has a sample using "CreateTimerQueueTimer" in Delphi (compatible with Delphi7), that would be cool.
  4. The problem is not the frame-update speed (which on my PC is about 3ms), it's about how to time the call to update the screen within a specific time-frame and not in 16/32ms intervals.
  5. I want smooth scrolling, using Sleep(1), I measure 15-30ms delay per frame, resulting in unstable scrolling because the delay between screen-updates is inconsistent/juddery and ~33fps which looks really bad.
  6. I use a thread to update an animated 'please wait' dialog while doing other things in the background. The issue is, I want to be able to dismiss the please wait dialog instantly and since I use animations, I use "Sleep" commands to to time the animation and take minimum CPU time. However, for some reason, doing Sleep(10) returns a vastly different result than calling For I := 0 to 1 do If Terminated = False then Sleep(5); which for some reasons takes ~30ms to complete. For reference, calling For I := 0 to 9 do If Terminated = False then Sleep(1); takes ~150ms. My problem is with Delphi 7, but I doubt it's specific to this version of Delphi, any ideas?
  7. Yaron

    Issues with Sleep(1) called in a loop

    Nevermind, I replaced Sleep with WaitForSingleObject and used an event to break out of the wait when closing the dialog.
  8. I wonder if anything in my code is not thread safe as I get the occasional random freezes in the copy-background code (bitblt functions) when using multiple threads. As you can see, all the bitmaps are created within the thread's execute function and their source data is coming from bitmaps in the main thread that is copied over within a critical section. This is using Delphi 7. procedure TThumbRendererThread.Execute; var thumbBitmapDarkL : TBitmap; backgroundBitmap : TBitmap; WorkBM : TBitmap; begin thumbBitmapDarkL := TBitmap.Create; backgroundBitmap := TBitmap.Create; WorkBM := TBitmap.Create; WorkBM.Width := thumbWidth; WorkBM.Height := thumbHeightTotal; BackdropChanged := True; While (Terminated = False) do Begin If BackdropChanged = True then Begin csThumbRenderer.Enter; Try // Copy bitmaps from main thread (within Critical Section) thumbBitmapDarkL.Assign(LibNavForm.thumbBitmapDark); backgroundBitmap.Assign(s_mlBackground); Finally csThumbRenderer.Leave; End; BackdropChanged := False; End; DebugLog('Copy backgrounds (before)'); BitBlt(WorkBM.Canvas.Handle,0,0,thumbWidth,thumbHeight,thumbBitmapDarkL.Canvas.Handle,xOfs,yOfs,SRCCOPY); BitBlt(WorkBM.Canvas.Handle,0,thumbHeight,thumbWidth,thumbHeightTotal-thumbHeight,BackgroundBitmap.Canvas.Handle,xOfs,yOfs+thumbHeight,SRCCOPY); DebugLog('Copy backgrounds (after)'); // Do other things End; WorkBM.Free; backgroundBitmap.Free; thumbBitmapDarkL.Free; end;
  9. No, I don't use TJPEGImage at all, I'm basically compositing several tbitmaps, writing a bit of text on an image and using 'fill' to draw a small box (for Zoom Player's media library thumbnails), The canvas are all locked and the issue only seems related to brush colors.
  10. I ended up writing my own bitmap based fill function, since it has a lot less overhead (my code needs less sanity checks as the input values are always in valid ranges), it's about 40% faster than Delphi's implementation, so win-win. Although I resolved the issue, if anyone knows the "recommended" method of using brushes with threads, I'd be interested.
  11. @David Heffernan The entire threaded code is written within the canvas's lock section and works without any issues (font drawing and bitmap operations), except for the brush color which occasionally seems to use the wrong color. I didn't paste the entire code for simplicity.
  12. Looks like I have to raise this thread from the dead. Even though I'm calling Bitmap.Canvas.lock and no other thread is writing to the canvas, I rarely get a weird fill color issue. This is a subset of the code: WorkBM.Canvas.Lock; Try WorkBM.Canvas.Brush.Color := clRed; WorkBM.Canvas.FillRect(barRect); Finally WorkBM.Canvas.Unlock; End; Somehow, the fillrect colors occasionally (very rarely) swaps to a different color. Do brushes require a separate type of lock?
  13. I am trying to upload JSON data and an image as a MultipartFormData and return a JSON string from mars using the following code: var shareData : TMultipartFormData; jsonStr : String; begin shareData := TMultipartFormData.Create; shareData.AddField('json','{"empty":"empty"}'); shareData.AddFile('image',FileName); jsonStr := NetHTTPRequest.Post(urlAPIBase+urlAPIShareImage,shareData).ContentAsString(TEncoding.UTF8); end; How do I setup mars to give me access to the json field and image fields? I looked at the ContentTypes demo, but I wasn't sure if any of the examples actually covered MultipartFormData.
  14. I've noticed 2 new warnings when uploading to the play store: --- Warning This App Bundle contains Java/Kotlin code, which might be obfuscated. We recommend you upload a deobfuscation file to make your crashes and ANRs easier to analyze and debug. Warning This App Bundle contains native code, and you've not uploaded debug symbols. We recommend you upload a symbol file to make your crashes and ANRs easier to analyze and debug. --- These warnings only affect ANR reports, but should I take steps to correct them?
  15. I use an FMX TWebBrowser component with Android to display a web form. The form is used to upload an image to a web server, however, after loading the web-page, clicking on the form's "Browse" button does absolutely nothing. Ideally, I would want Android to trigger the gallery app to select a picture for upload (like it does if I open the same URL with chrome/firefox), any ideas?
  16. Yaron

    My open-source portfolio

    I released quite a bit of interesting code to github over the years: YouTube DATA API v3 parsing: https://github.com/bLightZP/Delphi-YouTube-Channel-parsing-plugin-for-Zoom-Player Basic RSS feed parsing code: https://github.com/bLightZP/Delphi-RSS-feed-parsing-plugin-for-Zoom-Player TheAudioDB MetaData/Image scraping code: https://github.com/bLightZP/Delphi-theaudiodb.com-Zoom-Player-media-scraping-plug-in TheMovieDB MetaData/Image scraping code: https://github.com/bLightZP/Delphi-themoviedb.org-Zoom-Player-media-scraping-plug-in OpenSubtitles.org subtitle search & scrape code: https://github.com/bLightZP/Delphi-OpenSubtitles.org-API-support-for-Zoom-Player A basic cross-platform calculator https://github.com/bLightZP/ElegantCalculator https://play.google.com/store/apps/details?id=com.inmatrix.ElegantCalculator Adapted old code to work as cross-platform pure-pascal image scaling with filters (bicubic, bilinear, etc): https://github.com/bLightZP/ImageInterpolation Adapted old code to work as a cross-platform drawing of an anti-aliased circle (can be modified to draw rount-rect as well): https://github.com/bLightZP/AntiAliasedCircle I forked a QRCode generating source code and greatly optimized it (~ x50 faster): https://github.com/bLightZP/DelphiZXingQRCode The original Delphi scanline color-conversion implementation was very slow, so I optimized it: https://github.com/bLightZP/OptimizedDelphiFMXScanline
  17. I'm not using any external java files.
  18. @aehimselfnot using a VM @dummzeuchI changed the folder permission to allow full control to the user-account, had the same setup in Win7.
  19. @rvk Thank you, I've disabled exploit protection for "c:\Program Files (x86)\Borland\Delphi7\Bin\delphi32.exe" and my app's executable to see if it helps. @Arnaud Bouchez I wasn't ware of delphispeedup, I'll give it a shot. And by "slow", I mean about 50% slower compile times and longer load time when running the app from within Delphi.
  20. I've added the entire Delphi folder and my entire development partition (all my projects are on a separate drive) to the Exclusion list, but it didn't have an impact on the compilation/execution slowdowns. I tried the compatibility troubleshooter which suggested running as Win XP SP3, but when doing so, I couldn't even run my applications from Delphi, it just froze. Trying Win7 compatibility now to see if it works any better (at least apps run).
  21. Doesn't look like there's going to be an official patch, but it took me less than 5min to get this done, so it's not that tedious.
  22. Horácio posted a fix in the original thread, I verified that it works on a OnePlus 7 device running Android 10.
  23. I can't even vote because my subscription ran out...
  24. I am trying to write Android intent code so when a user chooses to share text with another application, my app will appear twice as an option, each with a different label and a mechanism I can distinguish between the two intents. Basically, I'm trying to have "Play" and "Queue" options for URLs shared from the YouTube app. I have no issues with just one intent, defining in "AndroidManifest.template.xml" <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> And in code: // Register the type of intent action that we want to be able to receive. // Note: A corresponding <action> tag must also exist in the <intent-filter> section of AndroidManifest.template.xml. MainActivity.registerIntentAction(TJIntent.JavaClass.ACTION_SEND); TMessageManager.DefaultManager.SubscribeToMessage(TMessageReceivedNotification, HandleActivityMessage); procedure TMainForm.HandleActivityMessage(const Sender: TObject; const M: TMessage); begin if M is TMessageReceivedNotification then HandleIntentAction(TMessageReceivedNotification(M).Value); end; function TMainForm.HandleIntentAction(const Data: JIntent): Boolean; var Extras : JBundle; sURL : String; begin Result := False; if Data <> nil then begin Extras := Data.getExtras; if Extras <> nil then Begin sURL := JStringToString(Extras.getString(TJIntent.JavaClass.EXTRA_TEXT)); {$IFDEF TRACEDEBUG}AddDebugEntry('Intent string "'+sURL+'"');{$ENDIF} Extras := nil; End end end; How can I add a second intent?
  25. If anyone is interested, here's the relevant section of the manifest file after I tested it works correctly: <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity" android:label="ZP Remote" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" android:launchMode="singleTask"> <!-- Tell NativeActivity the name of our .so --> <meta-data android:name="android.app.lib_name" android:value="ZP_Remote" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter android:label="Play in ZP"> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> </activity> <activity-alias android:targetActivity="com.embarcadero.firemonkey.FMXNativeActivity" android:name="com.embarcadero.firemonkey.FMXNativeActivity.Queue"> <!-- Put second SEND action inside activity-alias tag --> <intent-filter android:label="Queue in ZP"> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> </activity-alias>
×