gpu – Unity take screenshot without blocking?

I’ve been trying to actually use Unity’s AsyncGPUReadback.Request with Jint in JavaScript also, but mainly just in C#, to make a basic screenshot without the use of IEnumerable or yield return new WaitForEndOfFrame or something (don’t remember exactly), but I want to use it only with checking the .done property in an Update loop. I have not been able to find any examples online, though I have read the documentation on it multiple times.

First this attempt

var cam = Camera.main;
            RenderTexture rat = new RenderTexture(
                1920, 1080, 24
            );
            cam.targetTexture = rat;
            Texture2D actual = new Texture2D(
                1920, 1080,
                TextureFormat.RGB24, false
            );
            cam.Render();
            RenderTexture.active = rat;
            
            
        /*  actual.ReadPixels(new Rect(0, 0, 1920, 1080),
                0,  0);*/
                
            var reqt = AsyncGPUReadback.Request(rat);
            System.Action fncc = null;
            fncc = new System.Action(() => {
                if(reqt.done) {
                    Debug.Log("well" + reqt.ToString());
                    var data = reqt.GetData<byte>(0);
                    Debug.Log(data);
                    Yaakov.removeEvent("Update", fncc);
                }
                
            });
            Achdus.Yaakov.on("LateUpdate", fncc);//just some custom function to add events to the "Update" loop without monbehaviorus...
            
            cam.targetTexture = null;
            RenderTexture.active = null;
            var bite = actual.EncodeToPNG();
            System.IO.File.WriteAllBytes(
                path, bite
            );

gives me an error InvalidOperationException: Cannot access the data as it is not available, have absolutely no idea how to fix this

By combining some functions from the FFMPegOut library as well as (another script I found on github)(1) I kind of almost got something

static Material blat;
        public static 
        void GetScreenshot(
            string path,
            System.Func<object, object> fnc
        ) {
            
            
            var cam = Camera.main;
            var form = (
                cam
                .allowHDR ? RenderTextureFormat
                    .DefaultHDR 
                :
                RenderTextureFormat.Default
            );
            int aal = cam.allowMSAA ? QualitySettings.
                antiAliasing : 1;
            int width = 1920;
            int height = 1080;
            RenderTexture rt;
            GameObject bl;
            if(cam.targetTexture == null) {
                rt = (
                    new RenderTexture(
                        width, height,
                        24, form
                    )
                );
                
                rt.antiAliasing = aal;
                
                cam.targetTexture = rt;
                
                bl = FFmpegOut
                    .Blitter
                    .CreateInstance(cam);
            }
            if(blat == null) {
                var shayd = Shader.Find(
                    "Hidden/FFmpegOut/Preprocess"
                );
                blat = new Material(shayd);
            }
            
            var temp = RenderTexture.GetTemporary(
                cam.targetTexture.width,
                cam.targetTexture.height,
                0,
                RenderTextureFormat.ARGB32
            );
            
            Graphics.Blit(
                cam.targetTexture,
                temp,
                blat,
                0
            );
            
            var raq = UnityEngine
                .Rendering
                .AsyncGPUReadback.Request(
                    temp
                );
                
            System.Action fncc = null;
             var k = 0;
            fncc = new System.Action(() => {
                if(raq.done) {
                    Debug.Log("ok man" + raq);
                    var newTaxt = new Texture2D(
                        cam.targetTexture.width,
                        cam.targetTexture.height,
                        TextureFormat.ARGB32, false
                    );
                    
                    newTaxt.LoadRawTextureData(
                        raq.GetData<uint>()
                    );
                    
                    newTaxt.Apply();
                    
                    System.IO.File
                    .WriteAllBytes(
                        path,
                        ImageConversion
                        .EncodeToPNG(newTaxt)
                    );
                    Debug.Log("ok");
                    Yaakov.removeEvent("Update", fncc);//not important here just imagine its all in another update
                }
            });
            Achdus.Yaakov.on("Update", fncc);//same as earlier just the same thing as having the above in an "Update" loop just without monos....
            
            RenderTexture.ReleaseTemporary(temp);
            
        }

which doesn’t give any errors but returns this
(!(enter image description here)(2))(2)
Don’t see much? Neither do I…

So does anyone actually know how to take a simple screenshot with AsyncGPUReadback.Request WITHOUT any IEnumerators?

And BTW, for those just wondering why not IEnumerators, many reasons, but when I try to use the script from Github I literally get no result unity 2020:

using UnityEngine;
using UnityEngine.Rendering;
using System.IO;
using System.Collections;

public class AsyncCapture : MonoBehaviour
{
    IEnumerator Start()
    {
        while (true)
        {
            yield return new WaitForSeconds(1);
            yield return new WaitForEndOfFrame();

            var rt = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.ARGB32);
            ScreenCapture.CaptureScreenshotIntoRenderTexture(rt);
            AsyncGPUReadback.Request(rt, 0, TextureFormat.ARGB32, OnCompleteReadback);
            RenderTexture.ReleaseTemporary(rt);
        }
    }

    void OnCompleteReadback(AsyncGPUReadbackRequest request)
    {
        if (request.hasError)
        {
            Debug.Log("GPU readback error detected.");
            return;
        }

        var tex = new Texture2D(Screen.width, Screen.height, TextureFormat.ARGB32, false);
        tex.LoadRawTextureData(request.GetData<uint>());
        tex.Apply();
        File.WriteAllBytes("test.png", ImageConversion.EncodeToPNG(tex));
        Destroy(tex);
    }
}

it just seems to hang forever… but regardless I want to do this without IEnumerators
(1): https://github.com/keijiro/AsyncCaptureTest/blob/master/Assets/AsyncCapture.cs
(2): https://i.stack.imgur.com/0QMUb.png

adblock – Have they (uBlock Origin) just given up on blocking ads or what?

Once again, Twitch has started blasting me with these vile ads. I use uBlock Origin for a reason, and that reason is to never, ever be subjected by vile ads. Somehow, they have (yet again) found a way to bypass the adblockers to violate their users, as if it wasn’t already bad enough that the entire site is all about paying money constantly.

It’s been like this for weeks now. I have to wonder: have they just given up at this point? It seems that way to me. The site is 100% unusable in this state. I’m scared to load a stream as it’s very likely that it will instantly (ads load incredibly fast compared to everything else) start playing loud, obnoxious, unwanted ads for things I will never, ever buy, but rather actively avoid like the plague.

U.S. to start blocking TikTok and WeChat downloads Sunday

[SIZE=2][FONT=verdana][COLOR=#2A2A2A][SIZE=2]The U.S. will begin blocking the distribution of the Chinese apps TikTok and WeChat on Sunday, … | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1822528&goto=newpost

multithreading – Java blocking queue download process scenario

I have the following scenario .

I have incoming file download requests and each download is happening in different thread until pool size is exceeded. And after a download completed, a processor processes the downloaded item. So I created the following. I wonder if uses of thread and executors make sense

DownloadTaskProcessor

public class DownloadTaskEnqueuer {
    private static final BlockingQueue<Task> downloadQueue = new LinkedBlockingQueue<>();
    private static final BlockingQueue<Task> processQueue = new LinkedBlockingQueue<>();
    private static final ExecutorService executor = Executors.newCachedThreadPool();

    public void offer(Task task) {
        return downloadQueue.offer(task);
    }

    public void createPool(int size) {
        for (int i = 0; i < size; i++) {
            executor.execute(new DownloadTask(downloadQueue, processQueue);
            executor.execute(new ProcessTask(processQueue));
        }
    }
}

Download task

public class DownloadTask implements Runnable {
    private BlockingQueue<Task> downloadQueue;
    private BlockingQueue<Task> processQueue;
    
    // constructor for initing two queue

    public void offer(Task task) {
        return processQueue.offer(task);
    }
    
    @Override
    public void run() {
        while (true) {
           Task task = downloadQueue.poll();
           if (task != null) {
               task.getDownloadTask().download();
               offer(task);    
           } else {
               // sleep 250 ms 
           }
        }
    }
}

Process task

public class ProcessTask implements Runnable {
    private BlockingQueue<Task> processQueue;
    
    // constructor for initing queue
    
    @Override
    public void run() {
        while (true) {
           Task task = processQueue.poll();
           if (task != null) {
                task.getProcessTask().process();
           } else {
               // sleep 250 ms 
           }
        }
    }
}

Use case (pseudo)

createPool(10);

listener.listen((task) -> {
    downloadTaskEnqueuer.offer(task);
}

wordpress admin-ajax.php blocking with Pop-ups?

I am using Pop-ups and want to place a table inside the pop up. It will not display due to admin-ajax calls being blocked for some reason. Is this a standard that happens with other pop-ups and what is the solution so they will display?

java – Effective thread usage under blocking scenario

I have the following scenario.

I am listening file requests and when one arrives, I am starting download task in a new thread. After download task ends, a process task starts but this is important, process task must wait for download task. To do that, I can use dt_thread.join() or just stop using thread and download in blocking way. But in both cases, upcoming file requests get blocked and this turns out to be a performance issue.

I need to handle download tasks in threads but also need to ensure that process tasks start after relevant download task.

What kind of thread logic can I apply?

public void activateListener() {
    fileRequestService.listen((name) -> {
        DownloadTask dt = new DownloadTask(); // DownloadTask implements Runnable
        Thread dt_thread = new Thread(dt);
        dt_thread.start();

        ProcessTask pt = new ProcessTask(); // ProcessTask implements Runnable
        Thread pt_thread = new Thread(pt);
        pt_thread.start();       
    }
}

unity – Isometric Tilemap is blocking UI elements

I’m using Unity 2019.4.6f1, and I’m working on Isometric Tilemaps.

The hierarchy is like this:

Hierarchy

The VillageScreen is a Canvas, img-bg is an UI Image, the two Panels are UI Panels, and the Grid and two Tilemaps are the isometric tilemaps. The problem is, the Grid & Tilemap is blocking all other UI elements, and it seems to be always on top, no matter how I set the Z value.

The Grid setting is:

Grid Settings

And the Panel setting is:

Panel Settings

My question is: How do I put the UI elements ABOVE the Tilemap?

p.s. the UI button is clickable, it just cannot be displayed properly.

UPDATE: Added a mockup screen – Black circles are buttons, while Red texts are UI texts for displaying scores.

Mockup

CDN & Caching Blocking Email Automation

I’m using Groundhogg with WordPress. I have caching through Litespeed’s plugin, Cloudflare (DNS records are only in my CPanel), and the server itself. All three, together and individually, block emails being sent using Groundhogg. Groundhogg is an email marketing and automation tool. Users cannot get through the basic opt-in funnel. They’ll submit the form and get the confirmation email. When they click the confirm link, they’re oddly taken to a “manage your preferences” page instead of a “you are confirmed” page. They do not receive the welcome email that delivers the lead magnet.

My host is Hostinger, which is a Cloudflare partner. You manage your DNS in Hostinger, not Cloudflare. There are no orange/gray clouds to turn on or off.
SEMrush

Groundhogg’s CEO mentioned turning off caching for WP’s Rest API and otherwise said it should work with Litespeed, WP, and Cloudflare just fine. What am I missing?

Thanks.

 

bing webmaster tools – Cloudflare is blocking Bingbot

When I check BingWebmaster and use “Fetch as BingBot” then Bing is able to crawl that particular URL of my site. However, when I use SiteScan tool, then I am getting 4xx error. (SiteScan tool shows where we need on-page SEO improvements and that’s why it is very important that SiteScan tool works.)

Then I tried TechnicalSEO tool to fetch&render and I did the test as follows for Bingbot useragent:

and then found that CloudFlare forbids Bingbot useragent and results into HTTP 403 response.

HTTP/2 403 
date: Thu, 06 Aug 2020 01:46:22 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=d3f73e32abc0f9b1a8717b943883ee1b41596678382; expires=Sat, 05-Sep-20 01:46:22 GMT; path=/; domain=.playerauctions.com; HttpOnly; SameSite=Lax
cache-control: max-age=15
expires: Thu, 06 Aug 2020 01:46:37 GMT
x-frame-options: SAMEORIGIN
cf-request-id: 04630bbbc4000002c02a114200000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 5be51572dbc202c0-SEA
content-encoding: gzip
  • I reached out to Bing helpcenter and they said check with your Network team.
  • Network team said they couldn’t find anything at CloudFlare which is blocking Bingbot.

I have checked posts on CloudFlare Forum on Bingbot not able to access to my site, Cloudflare bing bot block and Bingbot blocked however none of them works.

So what should I do to fix this problem?