UpdateTextureRegions crashes on IOS

Hi people:
I used the UpdateTextureRegions() depicted in this wiki A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums to dynamically update texture, it works fine on Mac, but crashes instantly on IOS since the app started. The BulkData.Lock works well on IOS, however it is just too slow, is there anyone managed to use UpdateTexutreRegions( ) on IOS?

Thanks

btw, I tried to use the method RHIUpdateTexture2D(), however it crashes even on Mac.

This looks like an issue be proposed long beofre but still have no answers: UpdateTextureRegions crashes on IOS - Mobile - Epic Developer Community Forums

Can engine developers have a look?

Hi , this is an unfortunate consequence of the RHI looking D3D11-ish; for now you can change the check() to if (FOpenGL::SupportsPixelBuffers())… and add an else clause that calls RHILockTexture2D(), memcpy and then RHIUnlockTexture2D(). I’ll add a ticket to investigate this.

]
Hi , this is an unfortunate consequence of the RHI looking D3D11-ish; for now you can change the check() to if (FOpenGL::SupportsPixelBuffers())… and add an else clause that calls RHILockTexture2D(), memcpy and then RHIUnlockTexture2D(). I’ll add a ticket to investigate this.
[/QUOTE]

Really thank you for reply, Maybe in UE4.5.2 this will work on IOS?

So eventually since pixel buffer object is not available in OpenGL ES2, it is impossible to call the UpdateTextueRegion( ).

for the Lock/Unlock and memcpy solution, I tried it on Mac, but it crashes too…
the call stack is shown below

and my source code is

// Called by Tick event from BluePrint

UPROPERTY(BlueprintReadOnly, Category="Default")
UTexture2D* TVScreen;

void xxxx::UpdateFrame()
{
//do something

uint32 Stride = 0;
FTexture2DResource *Res = (FTexture2DResource*)TVScreen->Resource;

uint8* DestTextureData = (uint8*)RHILockTexture2D(Res->GetTexture2DRHI(), 0, RLM_WriteOnly, Stride, false);
FMemory::Memcpy(DestTextureData, NewData, TVWidth*TVHeight*nchannels);
RHIUnlockTexture2D(Res->GetTexture2DRHI(), 0, false);

}

this piece of code is almost same as the BulkData.Lock solution:

FTexture2DMipMap& Mip = TVScreen->PlatformData->Mips[index];
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(Data, NewData, TVWidth * TVHeight * nchannels);
Mip.BulkData.Unlock();
TVScreen->UpdateResource();

however, this solution just works fine, currently on iphone6 I have to lower the resolution of texture to 512x512, it is acceptable on Mobile, but it will be really good to have higher resolution…

Thanks

Just in case anyone finds this, the assert will be removed in 4.9, so these update functions should work in future. RHI functions have to be called on the render thread, which is why it crashes in 's code - the call is occurring on a game thread which is not permitted.