Low Entry Plugins

By the way, not sure if it’s still relevant, but I was thinking a long time about how to solve the problem with concurrent function calls in blueprint, and the main problem was not just the concurrency in itself, but also the “context”, as in, the variables at the time of calling the function call.

In my demo game I have one big class in which I have all my network code (this was a mistake by the way since it causes the editor to lag severely now, too much code in one file apparently). Anyway, in that class, I have functions/events that code from elsewhere can call. Some network functions (like “change username” etc) also have parameters that are used later on (after the function call is done). This works fine (except for Objects which can get garbage collected while waiting for the function call), but, when calling the same network function twice, the parameters of the function are overwritten by the second call. Other languages got "context"s for this, as in, whenever a function is called, it has its own local variables, when a function is called twice, it doesn’t override each others variables, they both have their own stack/context.

I now think, to solve both concurrency as well as the context problem, each network function should be programmed in its own class. Then when it is required to run, a new instance of that class should be made, and the event/function should be called that will run the (latent) function call. This way, the function call can be done concurrently, plus, if there are any parameters or local variables, you can store them in that class, and each class basically has its own “context” or “stack” so variables won’t override each other. Not only that, but it will also divide your network code into multiple classes, so you won’t ever have the editor lagging because you put all the code in the same file.

I think handling network code that way in the UE4 is the best way to do it. It solves the concurrency problem, it solves the context problem, it’s just a bit of a pain to create classes in the UE4, but that little bit of extra effort saves you from a lot of problems you would have had otherwise.

Thanks for the info.

Recently we implemented a simple FiFO stack in C++ to manage sent packets.

I believe you had suggested that previously.

This sorted out some issues that we were having with packets overriding each other.

Ah yeah that’s great, that should solve the concurrency problems (although it will only allow 1 function call to go at once with that of course).

It won’t solve the context problem in blueprint, as in, if you need to use a variable or parameter after a function call (or after any latent/delay blueprint really), then it could either be overwritten already, or in the case of Objects, they could be garbage collected (and thus, be “invalid” / null). If you don’t use any variables or parameters after a function call, then this is something you won’t have to deal with.

Just as an example, in my code, I always use Latent Action objects to let the caller be able to wait for the function call (kinda like a Promise in javascript for example). For example, my code looks like this:

Calling code (click the thumbnail below for a larger image)

Wrapper around the network function/event (click the thumbnail below for a larger image)

The network function/event (click the thumbnail below for a larger image)

Now, in my network event, I have the Latent Action as a parameter (as well as a String in this example), both the Latent Action as well as the String are used after the function call is done.

If this network event is called twice before the function call has ended, it will override the Latent Action, as well as the String, and then the application will bug (it will hang in my demo game).

I prevented this by not allowing any user interaction for as long as a Latent Action is waiting to be finished anywhere (which is what my demo game functions “Start Loading” and “Stop Loading” do).

I did this because I didn’t see a proper way to handle function/event context before, but now, it’s clear that instead of just having the network function/event there, I should have placed it in a class, and gave that class a Latent Action and a String variable, and then just set those before calling a function/event inside of that class (that would run the function call inside of the class then).

If you’re having similar problems (or anyone else reading this), and I think this problem is somewhat common with network code, then this is the solution that will solve the concurrency as well as the context problem in blueprint. I hope it will help you in case you’re running into something similar to this as well at one point.

I still haven’t been able to resolve the problem. I tried various Android packaging types in UE4 as well as packaging on Windows and MacOS, no difference. Is there something special I need to do to get the plug-in working on Android arm64? It definitely isn’t a 64-bit problem as it works fine on Win64, MacOS (which no longer supports 32-bit anyway) and iOS 64-bit. I’ve also tested this on a fresh project with the same results.

I see, I doubt it’s related to the plugin code, it’s most likely the android compiling workflow (in the UE4) in which something is failing.

I remember, when setting up Android compiling, you have to install the SDK and select everything relevant to you right? Perhaps you didn’t select the 64 bit libraries/options needed for 64-bit arm64 compilation?

Also I would post this problem on the UE4 answerhub, Epic employees will usually help you and look into it when you post a bug report on the UE4 answerhub. That being said, I think it’s most likely a problem with the libraries/options thing I talked about earlier, since something like that could easily cause the problem you’re having. If that isn’t the case, then I would most definitely post it on the UE4 answerhub to get help with this problem.

Also, just to isolate the problem, you could try packaging a UE4 C++ project to android 64-bit arm64, just to make sure it isn’t anything in the plugins that’s causing this. If you post this problem on the UE4 answerhub, they’ll most likely ask you to do the same thing as well, so you’d save some time by doing that in advance already.

Anyway, I hope that helped.

Hi,

I’ve tried with a C++ project, same result. I installed EVERYTHING in CodeWorksforAndroid 1R7u1 (windows and mac), same result. I’ll ask in the UE4 Answerhub. Fingers crossed a solution can be found. And yes, it’s definitely an Android-specific problem, as the plug-in works just fine in Win64, MacOS64 and iOS64. Thanks for the help!

No problem, thanks for the update, I hope you’ll get an answer on the answerhub soon.

@ So, UE4 is into 4.23 and there is no support for mic audio input for Android :frowning: (especially with exposure to BP). Is there any way you could add such support to LE Standard Library or make a standalone plugin (paid) for Ue4 ?

Hey sadly I don’t think that’s really doable currently, since nothing for that functionality is exposed by the UE4 C++ API. It might be doable by creating your own android (java) code and then accessing that through C++, I’m not sure, that would require some experimentation, but I currently don’t have the time required to do that.

Possibly there is C++ API, since this dev messed with it? https://answers.unrealengine.com/que…3082/view.html (although his solution isn’t in BP)

Ah I see, didn’t notice the Voice module. It seems to be doable to record audio to bytes, and to compress/decompress it. I’m not sure yet on how to convert the bytes to UE4 audio/sound yet, but that shouldn’t be hard to do either. Making a plugin out of this should be possible, well if it wasn’t for the time it needs (to debug and test things mostly). I currently don’t have enough time for the work I have as it is, so I can’t really add another project on top of it at this moment. It seems easy enough to do it yourself though, you’ll just have to figure out how to convert the bytes to audio, at least, assuming that’s what you want to do with it? What do you want to do with the mic input?

Well, if I was a C++ programmer, I wouldn’t be asking :wink:

I want to get status of mic (on/off), turn it on/off from BP or/and toggle it from BP, get volume value from BP (to see if player is breathing heavy into mic, whispering or talking loud, etc. and based on that do something in-game).

I see, not sure if you can turn it on or off (unless you handle the entire audio-playing part of the voice data manually). Getting the volume might be doable, not 100% sure, don’t know how the PCM format works yet. Anyway it seems like a minor feature, perhaps you could drop it? Or you could hire a programmer to create a small plugin for it, would probably cost just 3000 euro or so.

Hi, currently looking into your byte facilities, and have a couple of questions:

  • How does the byte reader work exactly? Does it consume bytes as it reads them? Does it consume all bytes if it reads into an array?

  • Is it possible to cast a Low Entry Double to an UE4 Float?

Thanks!

Hi, belated update. I have resolved the problem via the completely overlooked solution of copying the plugin folder to the project folder. Unreal Engine seems not to have copied the plugin code to the arm64 version of the app. I’ll submit a bug report to Epic Games about it.

Aah that makes sense. Thanks for letting me know! I hope Epic will do something with this as well, so that other people won’t have to stumble upon this problem as well.

Is there any reason the double type is a full blown object rather than a struct? It would make a hell of a difference.

You mean the Double and Long objects in the LE Extended Standard Library? They’re just wrappers around a byte array, there’s no real reason they are objects rather than structs. What advantage would it have if they were structs instead of objects?

Just a much smaller payload. I’ll take a crack at porting them to structs soonish and submit a PR if I can pull it off with some redirectors so existing users don’t get upset. I wanted to check with you first to see if there was a particular reason.

That would be great if that’s possible. The biggest thing about the rework is whether it would break projects using the objects and functions that exist now. If you can figure out a good way of dealing with that with redirectors then it would be a great update.

Let me know when you’ve submitter a PR (like by sending a message on here).