I make an addon that scans inbound images to see if they’re NSFW and then replaces them with SVG placeholders if they are. It uses neural nets so the calculations are necessarily quite expensive. Given the nature of the use case, I must use
BlockingResponse as well as fully wait for the resource to load before I can start scanning.
Based on some limited tests I’ve done, it seems that the inbound requests never stack quite like I thought they might - that is to say, even though I’m using
async for good chunks of it, my inbound queue of work never seems to grow over size 1. This surprised me a bit and got me wondering if webRequests go in parallel at all when used in this
BlockingResponse mode. (“Blocking” in this sense could be interpreted in a couple different ways.) Does anybody know what the defined behavior here is?
Additionally, assuming that I’m not just doing something incorrect here, it seems that the only way to solve this would be to essentially have more than one background.js context doing some form of cooperative multitasking, which is I believe only possible with more than one addon. I’ve done some initial tests that lead me to think this would give a significant boost potentially. Is there any way to have more than one background.js context in an addon?
Thanks for your time!