UTexture2D::UpdateResource() not working in packaged application

In my project I’m making heavy use of “raw” texture updates, like this:


	// Calc buffer size
	size_t BufferSize = BackgroundTextureSize.X * BackgroundTextureSize.Y * 4 * sizeof(uint8);

	// Lock resource and get raw data (READ WRITE)
	uint8 *RawData = (uint8*)BackgroundTexture->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE);
	if (!RawData)
	{
		UE_LOG(LogTemp, Warning, TEXT("ResetBackgroundImage(): cannot read background texture data!"));
		return;
	}

	// Copy
	memcpy(RawData, BackgroundTextureDataCache, BufferSize);

	// Release resource
	BackgroundTexture->PlatformData->Mips[0].BulkData.Unlock();
	// Update resource
	BackgroundTexture->UpdateResource();

Everything works fine in PIE, Standalone Game and even Mobile Preview.
However, when I package the project for Windows (in development configuration) and launch the game, textures do not update. Why? Did I miss something?

What version of @UnrealEngine 4 are you using - and experiencing this problem ??

:]D

Version is 4.13.2

I tried in 4.10 and still nothing
Then I tried using UpdateTextureRegions method (which should be faster than locking/unlocking/updating resource): works in editor, crashes in packaged game.
Finally I created a whole new project (4.13) copying just a little part of the code (with UpdateTextureRegions), packaged it on the fly and it works! :mad:

Any idea what could be the problem with the original project? Maybe I messed up with settings? I really need to fix this, since the whole project revolves around it.

EDIT: tested on 3 w10x64 devices, on two of them (mid and high end) the unhandled exception is an ACCESS_VIOLATION, on the other one a INT_DIVIDED_BY_ZERO. The problem is caused by the UpdateTextureRegions call. Anyway a few times it worked without throwing any exception …