Auto Reimport Textures Broken

Hey engine team,

We have just finalized a plugin for UE4 that enables real-time texturing within the Unreal Engine. The plugin relies on the Auto Reimport Textures feature to reload textures in a specific directory as specified by the Auto Reimport Directories. It all works great on 50% of our test machines, but does not work at all on the rest of our machines. Even with a blank project setup and no custom plugins loaded, and Auto Reimport Textures checked, it simply does not react to changes in the Auto Reimport Directory.

Thus we have also tried to write a custom listener, but on 50% of our machines the issue remains – nothing happens. Here is our custom listener code for reference:

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.

#include "ListenerTestPluginPrivatePCH.h"
#include "Developer/DirectoryWatcher/Public/DirectoryWatcherModule.h"
#include "Developer/DirectoryWatcher/Public/IDirectoryWatcher.h"

class FListenerTestPlugin : public IListenerTestPlugin
{
	/** IModuleInterface implementation */
	virtual void StartupModule() override;
	virtual void ShutdownModule() override;

	/** Callback when folder changes */
	IDirectoryWatcher::FDirectoryChanged FolderChangedDelegate;

	/**
	* Adds a callback to directory watcher.
	*/
	void InitHotReloadWatcher();

	/**
	* Removes a directory watcher callback
	*/
	void ShutdownHotReloadWatcher();

	/**
	* Directory watcher callback
	*/
	void OnDirectoryContentsChanged(const TArray<struct FFileChangeData>& FileChanges);


};

IMPLEMENT_MODULE( FListenerTestPlugin, ListenerTestPlugin )



void FListenerTestPlugin::StartupModule()
{
	// This code will execute after your module is loaded into memory (but after global variables are initialized, of course.)
	InitHotReloadWatcher();
}


void FListenerTestPlugin::ShutdownModule()
{
	// This function may be called during shutdown to clean up your module.  For modules that support dynamic reloading,
	// we call this function before unloading the module.
	ShutdownHotReloadWatcher();

}

void FListenerTestPlugin::InitHotReloadWatcher()
{
	FDirectoryWatcherModule& DirectoryWatcherModule = FModuleManager::Get().LoadModuleChecked<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
	IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule.Get();
	if (DirectoryWatcher)
	{
		// Watch the folder for new files
		FString path = FString(TEXT("C:/QuixelTemp/"));
		FolderChangedDelegate = IDirectoryWatcher::FDirectoryChanged::CreateRaw(this, &FListenerTestPlugin::OnDirectoryContentsChanged);
		DirectoryWatcher->RegisterDirectoryChangedCallback(path, FolderChangedDelegate);
	}
}


void FListenerTestPlugin::ShutdownHotReloadWatcher()
{
	FDirectoryWatcherModule* DirectoryWatcherModule = FModuleManager::GetModulePtr<FDirectoryWatcherModule>(TEXT("DirectoryWatcher"));
	if (DirectoryWatcherModule != nullptr)
	{
		IDirectoryWatcher* DirectoryWatcher = DirectoryWatcherModule->Get();
		if (DirectoryWatcher)
		{
			FString path = FString(TEXT("C:/QuixelTemp/"));
			DirectoryWatcher->UnregisterDirectoryChangedCallback(path, FolderChangedDelegate);
		}
	}
}

void FListenerTestPlugin::OnDirectoryContentsChanged(const TArray<struct FFileChangeData>& FileChanges)
{
	UE_LOG(LogTemp, Warning, TEXT("DirectoryChanged Callback called!!!"));
	for (int i = 0; i < FileChanges.Num(); i++)
	{
		UE_LOG(LogTemp, Warning, TEXT("%s"), *FileChanges[i].Filename);
	}
}

We would like to know if this is a known issue, and would be happy to provide any additional information you may require in order to help reproduce it.

Thank you!

Hey Teddy Bergsman -

We are having a hard time reproducing this internally. So let me get a little bit more information, are you uploading a texture that is also in the auto reimport directory or just uploading a texture from anywhere on the machine? Also what version of the engine specifically are your testing on?

Let me know -

Eric Ketchum

Hi Eric,

Thank you for your reply! The process is as follows:

  1. Save texture to disk (D:/Textures/albedo.tga)
  2. Open UE4 project
  3. Import albedo.tga into project
  4. Set Auto Reimport Directories to D:/Textures/
  5. Set Auto Reimport Textures to true
  6. Edit and overwrite albedo.tga using Adobe Photoshop

At this point the texture is not automatically reimported. If I manually reimport the texture through the context menu it updates.

This has been tried on 4.3, 4.4, and 4.5. Important to note is that this exact process works on 2 machines, and fails on 2 other machines. On a fluke I had it work on the failing machines once, by creating a new empty project in 4.5 and then proceeding with the process listed above. The success could however not be reproduced in earlier versions of UE4, and regardless of version it would not work if I opened an existing project (Marketplace content for instance) and imported the textures the exact same way.

Let me know should you need anything else. Your support is much appreciated!

Hey Teddy -

One question in your reproduction steps are you setting as default in Editor Preferences after Step 5?

Thank You

Eric Ketchum

Thanks Eric,

I did not set the settings as default after Step 5. I’ve tried this now too, however it makes no difference. Here is a GIF demonstrating the exact process (now also setting the settings as default). Note how the texture does not reimport after having been inverted and resaved. Only if I right click and reimport manually the change will take effect:

Can you give me the system specifications for the machines where the reimport is not occuring? IN particular I am looking for any differences between the working specifications and the non-working specifications and anything that the test machines that do not work have in common like OS, maybe even a particular program installed.

Thank You

Eric Ketchum

Thank you Eric,

After a great deal of testing I have now been able to isolate the issue. Auto Reimport Textures only works if the texture files are located in the C:/ drive. The file watcher does not work with any other directory (D:/, for instance).

I hope this will be helpful to you in reproducing as well as solving the issue.

Thanks again!

Hey Teddy -

I haven’t had any luck so far on breaking the Auto Reimport. I am able to reimport from any drive on my computer. Can you let me know if your d drive is an external or networked drive? Also if you can let me know exact what the computers that are having this issue’s specifications are?

Thank You

Eric Ketchum

Hi Teddy,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information requested above and we will offer further assistance.

Thank you.

Eric Ketchum

Hi Eric,

My apologies for the delayed response, I had missed your last reply. Unfortunately this is still unresolved. The D:/ drive is neither an external nor network drive. Here are the specifications of four of the machines, two that are working and two that are not.


Custom built stationary - Reimport broken

Windows 7 Ultimate (Service Pack 1) 64-bit

Nvidia GeForce GTX 780 Ti

Intel Core i7-4770K @ 3.50 GHz

32GB DDR3

C:/: 128GB SSD; D:/: 2TB; E:/: 4TB


MSI GT70 Laptop - Reimport broken

Windows 7 Home Premium (Service Pack 1) 64-bit

Intel Core i7-3610QM

Nvidia GeForce GTX 680M / 4GB GDDR5

16GB DDR3

C:/ (reimport works): 128 GB SSD (Super Raid); D:/ (reimport broken): 750GB 7200RPM


Macbook Pro Laptop (2x of these) - Reimport works

OSX 10.9.4 Mavericks

2.5GHz Intel Core i7 4770HQ

16GB DDR3 SDRAM 1600MHz

1536MB (shared) Intel Iris Pro

256GB SSD


The only guesses I can make are that 1) the reimport functionality does not work on any of our Windows machines but on all OSX machines, or 2) that it only works on the drive that the operating system is installed on, or 3) that it only works on SSD drives.

Let me know if you need anything else!

Thanks,

Teddy

Hey Teddy -

I think I might have an idea and I am seeing if I can test it one a specific setup here, but if you look at the windows machines which are not working (or partly working) are the secondary drives slaved to the primary hard drives? I am not exactly sure why that would cause an issue but based on your data above and my own tests here that is the only variable that I have left to test.

My tests here have been based on this specification with it working on both C and D drives:
OS: Windows 7 Professional 64-bit
PROCESSOR: Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz (12 CPUs), ~2.1GHz
RAM: 32 GB RAM
VIDEO CARD: NVIDIA GeForce GTX 770
C: 256GB D: 2TB

I will let you know as soon as I have a results from the latest test but if you gather any more information please upload and let me know.

Thank You

Eric Ketchum

Hi Eric,

We’re still facing this issue at our end. Did you happen to find any other information on the tests you’ve been doing?

Thanks,
Sameer

Hey Sameer -

Unfortunately I have not been successful in reproducing this issue. In all setups including the Primary and Slave setup I mentioned above, all textures are importing and re-importing as expected.

I did think you could try to eliminate the Photoshop component of the test. On a Windows machine, import a PNG texture and setup your re-import texture directory. Instead of opening Photoshop to edit open Paint and edit then save and see if the editor on your machines pick up the texture change.

Thank You

Eric Ketchum

Hello,
same problem here.
The PC is a Asus ROG G20, with 2 drives : 1 SSD (one partition, C:) and 1 SATA (one partition D:).
If I set the textures in D: , for example D:\textures , the editor doesn’t update them when they change on disk, while on C: they are correctly updated.

Thank you,

Hey -

I am looking into this issue again. Currently I am attempting to get my hands on a CPU setup similar to your description. As soon as I know more information I will post here.

Thank You

Eric Ketchum

Ok, thank you. Let me know If I can do something to help you (sample scene, textures, whatever).

Hello Eveyrone -

I was finally able to get my hands on a PC with the SSD anf HDD setup and can say that I was still unable to get an error on reimporting the textures. I will say that you do have to do the initial import and then save the textures into the engine before the auto reimport texture function will kick in. So if you could test that and make sure that it is working for you, I will also say that I was testing on 4.7.3

Thank You

Eric Ketchum

Not sure if this is the same issue I was seeing, but I also had Auto-Reimport seem to fail randomly, but it turned out to only be when the Data Source Folder Editor Preference was set (this problem occurs as early as UE 4.21.2 and as late as UE 4.24 preview 1). I submitted a fix for it here: https://github.com/EpicGames/UnrealEngine/pull/6359