Repository: godot
Issue: GLTF files can prevent PNG/SVG files from being imported on Arm systems
Labels: bug,topic:import,regression,topic:3d

### Godot version

Latest master 2a0aef5f0912b60f85c9e150cc0bfbeab7de6e40 but different behavior on master

### System information

macOS 13.3 arm64 (also happens on Ubuntu Linux arm64)

We have narrowed down the bug in the comments, it seems to only happen on ARM, not x86.

### Issue description

Some hard-to-isolate situations can cause other files like PNG files to be permanently unimported. In some cases this can be fixed by deleting the `.import` files, but in some cases Godot gets stuck and it refuses to even regenerate the `.import` files let alone perform the import.

One of these situations can be triggered by the GLTF files in the attached minimal reproduction project. Part of this issue is a regression since 4.0-stable, part of it also exists in 4.0-stable.

### Steps to reproduce

* Open the minimal reproduction project with the latest master.
* Double-clicking on any of the PNG files gives an error that the resource can't be opened.
<details>

```
  Failed loading resource: res://torch/text/baseColor_1.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1263 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/text/emissive_1.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1263 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1263 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch_emissive.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1263 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
```

</details>

* Try deleting the `.glb` and `.gltf` files. Double-click on a PNG file. Same errors.
* Try restarting Godot after deleting the `.glb` and `.gltf` files. Double-click on a PNG file. Same errors.
* Try deleting the `.png.import` files. The PNG files will now import and load fine.
* Note: If the `.glb` and `.gltf` files are deleted before you start Godot for the first time, the PNG files load fine.
* It seems like a very serious bug in the import pipeline if something can cause a PNG file to never import.

---

Another problem that you can test in the same minimal reproduction project, this has regressions since 4.0-stable:

* Open the minimal reproduction project with the latest master.
* Double-click on the `.glb` file. The torch will be white. This is a regression, in Godot 4.0-stable the torch has the proper textures. In the console it prints these errors:
<details>

```
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch_emissive.png. Make sure resources have been imported by opening the project in the editor at least once.
  modules/gltf/gltf_document.cpp:3282 - glTF: Image index '0' couldn't be loaded with the name: minecraft_torch_emissive. Skipping it.
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch.png. Make sure resources have been imported by opening the project in the editor at least once.
  modules/gltf/gltf_document.cpp:3282 - glTF: Image index '1' couldn't be loaded with the name: minecraft_torch. Skipping it.
```

</details>

* Double-click on the `.gltf` file. Similarly, the torch will be white, a regression, and errors in the console. But also note how Godot creates 2 new PNG files when double-clicking on the `.gltf`.
    * First of all it's a bug that Godot tries to extract textures that are already separate files.
    * Second of all these are valid files, you can open them with GIMP, Firefox, etc, but Godot refuses to import them.
* Delete `icon.svg.import` in the root of the project. Now Godot will refuse to import `icon.svg`, and it does not generate the `icon.svg.import` file.
* Delete all `.png.import` files. Now Godot will import those, and it will also import `icon.svg`, and double-clicking on the `.glb` or `.gltf` files will result in the models having textures.
* Delete the `.glb.import` file. Try double-clicking it again and the texture will be white again.
* Delete `icon.svg.import` in the root of the project. Now Godot will refuse to import `icon.svg` (again), and it does not generate the `icon.svg.import` file (again).
* It seems like a very serious bug in the import pipeline if something can cause the `.import` files to not generate.

---

The first issue is also present in 4.0-stable, I have written some text about that collapsed:

<details>

* Open the minimal reproduction project with Godot 4.0-stable.
* Double-clicking on any of the PNG files gives an error that the resource can't be opened.
<details>

```
  Failed loading resource: res://torch/text/baseColor_1.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1209 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/text/emissive_1.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1209 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1209 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
  Failed loading resource: res://torch/minecraft_torch_minecraft_torch_emissive.png. Make sure resources have been imported by opening the project in the editor at least once.
  editor/editor_node.cpp:1209 - Condition "!res.is_valid()" is true. Returning: ERR_CANT_OPEN
```

</details>

* Try deleting the `.glb` and `.gltf` files. Double-click on a PNG file. Same errors.
* Try restarting Godot after deleting the `.glb` and `.gltf` files. Double-click on a PNG file. Same errors.
* Try deleting the `.png.import` files. The PNG files will now import and load fine.

</details>

### Minimal reproduction project

[wherearemyimports.zip](https://github.com/godotengine/godot/files/11379941/wherearemyimports.zip)