Commit graph

3015 commits

Author SHA1 Message Date
Rémi Verschelde e94161dada
SCons: Add explicit dependencies on thirdparty code in cloned env
Since we clone the environments to build thirdparty code, we don't get an
explicit dependency on the build objects produced by that environment.

So when we update thirdparty code, Godot code using it is not necessarily
rebuilt (I think it is for changed headers, but not for changed .c/.cpp files),
which can lead to an invalid compilation output (linking old Godot .o files
with a newer, potentially ABI breaking version of thirdparty code).

This was only seen as really problematic with bullet updates (leading to
crashes when rebuilding Godot after a bullet update without cleaning .o files),
but it's safer to fix it everywhere, even if it's a LOT of hacky boilerplate.

(cherry picked from commit c7b53c03ae)
2021-04-29 16:57:00 +02:00
Rémi Verschelde 70ae90e0e8
Core: Drop custom copymem/zeromem defines
We've been using standard C library functions `memcpy`/`memset` for these since
2016 with 67f65f6639.

There was still the possibility for third-party platform ports to override the
definitions with a custom header, but this doesn't seem useful anymore.

Backport of #48239.
2021-04-29 12:34:11 +02:00
Rémi Verschelde 1489b814aa
Android: Upgrade buildTools from 30.0.1 to 30.0.3
It seems 30.0.1 had issues with compatibility with JDK 8 and 11,
which appear to be solved in 30.0.3 as per godotengine/godot-docs#4796.

(cherry picked from commit d88e1f04df)
2021-04-29 12:28:51 +02:00
Rémi Verschelde 8ec14c917f
Merge pull request #47469 from HEAVYPOLY/ios-pen-pressure
Add iOS pen pressure
2021-04-28 17:01:05 +02:00
Fabio Alessandrelli 9446be7dad [HTML5] Export as Progressive Web App.
Adds possibility to export as a progressive web app.
Allows customizing base icons, display mode, orientation and offline
page.
2021-04-27 15:09:03 +02:00
Fabio Alessandrelli cb65f9d64b [HTML5] HTTP server uses optional SSL.
Generates a key/cert snakeoil pair or use a custom SSL cert/key.
This is of course false security, and potentially detrimental for it.

But, so long, those are the requirements browser vendors agreed on to
use things like the Gamepad API, and more advanced topics like wasm
threads.

You don't need this if you run on localhost (at least!), but you do
need this (or a much safer nginx proxy) to try those things on your
local network (e.g. when debugging a phone, networking, etc).
2021-04-27 15:09:03 +02:00
Fabio Alessandrelli a7f2b723d6 [HTML5] Optional icon generation, use export name for it.
We used to only generate the favicon if it was specified in the user
project settings, now it's optional, will export it to `NAME.icon.png`,
(falling back to the default project icon if none is set in project
settings), and the `<link>` tag is added using the `$HEAD_INCLUDE`
instead of being hardcoded in the template.
2021-04-27 15:09:03 +02:00
Fabio Alessandrelli ad160c7f46 [HTML5] Debug HttpServer now runs in web cache subdir.
Serving all files in that folder and using a known list of mime types.
Makes it easy to add more exported files, while still playing safe.
2021-04-27 15:09:03 +02:00
Rémi Verschelde 3b12daa10d
Linux: Remove use_static_cpp override on x86_32
After further testing it seems to work fine now when building binaries with GCC 5
on Ubuntu 16.04 (previously we were using GCC 9 on Ubuntu 14.04).

Follow-up to #45629.

(cherry picked from commit aa15ad72ee)
2021-04-27 13:44:04 +02:00
Rémi Verschelde 5820e36705
Android: Fix get_buffer false positive on empty dest buffer
Follow-up to #46810, this was missed in #47079 when fixing the issue
for other platforms.

Fixes #48135.

(cherry picked from commit a09f3833bd)
2021-04-23 21:49:31 +02:00
Rémi Verschelde a14b51df92
Linux: Don't attempt linking embree3 on non-tools, link it for headless too
`tech_debt++`, that's what we get for not taking the time to cleanup all this
and do it right...

Follow-up to #48073 and #48102.
2021-04-23 10:40:53 +02:00
Rémi Verschelde a2c68d9da7
lightmapper: Disable build if raycast module can't build
We need to propagate the hacky checks from the raycast config to the
lightmapper config, as the failure of a `can_build()` check is not notified to
other modules (which might even be checked further depending on the processing
order in SConstruct).

A more thorough fix would be to change SConstruct to do two loops on modules:
one to check `can_build()` and disable modules which can't build, then another
one to rechecked `can_build()` with the new lineup and do further config.
But there would be more risk for regressions than with this ad hoc hack.

Similar story for the `platform/x11/detect.py` change... oh my eyes :(
2021-04-22 19:12:37 +02:00
Rémi Verschelde b266cc2315
embree: Allow building against system library on Linux 2021-04-22 17:06:28 +02:00
Gromph d964b86249
Fix EditorExportPlugin _export_begin and _export_end functions not being called when exporting UWP
in uwp's version of export.cpp create a ExportNotifier object so that EditorExportPlugin _export_begin and _export_end functions will be called as documentated.

(cherry picked from commit 564ddcde77)
2021-04-20 20:12:53 +02:00
Rémi Verschelde d91c1a60a4
Merge pull request #47954 from m4gr3d/automatically_remove_legacy_storage_attribute
Disable the `requestLegacyExternalStorage` attribute when there are no storage permissions
2021-04-16 17:11:22 +02:00
Fredia Huya-Kouadio bc68872e2d Disable the requestLegacyExternalStorage attribute when there are no storage permissions. 2021-04-16 07:26:24 -07:00
Fredia Huya-Kouadio d7e5c8fad5 Fix issue causing export to fail with "Could not unzip temporary unaligned APK" error and improve command output logging. 2021-04-15 13:26:05 -07:00
Sergey Minakov cdd921e908
[iOS] Fix for plugin modified time check
(cherry picked from commit 15630a4931)
2021-04-14 13:29:55 +02:00
Fredia Huya-Kouadio 158c848ac5 Fix custom boot splash image scaling. 2021-04-12 16:39:32 -07:00
Fredia Huya-Kouadio dedeada310 Fix issue causing the response callback to be invoked with the invalid requestCode. 2021-04-09 13:38:36 -07:00
Bastiaan Olij abaa032fae
Fixes on android:
- checking for validity of ENV in wrapper classes
- fix for access to JavaVM from threads

(cherry picked from commit b3a43430aa)
2021-04-06 22:02:10 +02:00
Fabio Alessandrelli 00f3807a24 [HTML5] Implement WebGL fallback.
According to project settings and when WebGL2 is not available.
2021-04-06 12:56:45 +02:00
Fabio Alessandrelli f90b24a805
[HTML5] Disable body_size in fetch.
We were using `Content-Length` from the server when `Content-Encoding`
was not set (i.e. response was not compressed).

Sadly, in CORS requests accessing headers is restricted, and while
`Content-Length` is enabled by default, `Content-Encoding` is not.

This results in the impossibility of knowing if the content was
compressed, unless the server explicitly enabled the encoding header
via `Access-Control-Expose-Headers`.

To keep maximum compatibility we must disable `body_size` completely.

(cherry picked from commit 737ed0f66e)
2021-04-05 11:59:38 +02:00
Vaughan Ling f60b90d92e Add iOS Apple Pencil pressure 2021-04-03 10:30:57 -07:00
Fabio Alessandrelli 74fd9409d5
[HTML5] Fix WM notifications not being called.
Regression from the library refactoring, binding and not calling is
pretty useless 'o_o.

(cherry picked from commit 01658adb30)
2021-03-29 21:09:19 +02:00
Rémi Verschelde 10fb798883
Merge pull request #47456 from akien-mga/3.x-windows-mingw-aslr
Windows: Disable ASLR protection w/ MinGW, it breaks Mono
2021-03-29 19:06:44 +02:00
Fabio Alessandrelli b402c1cb17
[HTML5] Fix Mono builds (old emcc?)
Promise chaining the emscripten module `then` function breaks it badly,
causing an infinite loop.
I'm unsure about the source of the issue, but most likely at this point
is due to the old emscripten version (I remember very old html5 builds
having issue with promise chaining too).

With this commit, we no longer use the module as a promise, and
instantiate it using `Promise` objects directly for compatibility.

(cherry picked from commit ae3c9345cc)
2021-03-29 19:04:29 +02:00
Rémi Verschelde f7a999c814
Windows: Disable ASLR protection w/ MinGW, it breaks Mono
We might be able to make it work by building Mono itself with
ASLR protection too, but there might still be issues when loading
e.g. GDNative DLLs built without ASLR protection.

In the short term this is not a goal, but we can reconsider later
what is actually needed for ASLR protection to work and keep things
user-friendly.
2021-03-29 14:39:20 +02:00
bruvzg 7447c3b76c
[macOS] Enable code signing by default, use ad-hoc signature if no identity specified.
(cherry picked from commit 09c8e69232)
2021-03-29 14:29:54 +02:00
Hein-Pieter van Braam-Stewart ff3099abcf Fix thread_local, tls, ASLR, and DEP with MingW
This commit changes the way Thread::caller_id works. By moving caller_id
to the .cpp file we make sure that the TLS variable doesn't get
relocated twice causing a crash. Since we build with LTO for release
builds (and everyone should be doing that anyway) there is no extra
overhead from the non-static method. We do do an extra bool check now
there but I don't think this will add much in the way of overhead.

This check cannot be avoided if we still want to be able to cache the
thread ID hash, as we had to move the setter because of limitations of
the WinRT platform. The original workaround for this was in #46813 but
this has some unintended consequences. Specifically; threads that never
create a Thread object will always return 0 in Thread::get_caller_id()
which caused a regression. For instance the editor now freezes when
importing large textures. This PR also addresses that.

Additionally we now enable ASLR support when building with MingW, this
includes a workaround for MingW. MingW refuses to create an appropriate
relocation table if no symbols are exported. So we just export the
various main() functions in godot_windows.cpp.

While ASLR support isn't criticial for Godot, previous versions of Godot
just happened to work with a dynamic base 'by accident' and some users
run Godot this way. After the thread change the .tls section now needs
relocations to make this work. By enabling ASLR at build-time we create
these relocations and people who forced ALSR on previously will now get
a working Godot again.

This fixes #47256 and fixes #47219

This is the 3.x version of this PR. For master a different approach is
possible which I will make in the coming days.
2021-03-25 23:20:12 +01:00
Fabio Alessandrelli 6181452a54
[HTML5] Fix loading when mime-type is missing.
`WebAssembly.instantiateStreaming` requires the mime-type to be
`application/wasm`, but some servers (including most debug servers) do
not provide the content-type header.

This commit forces it via JavaScript, by creating a `Response` object
with the `wasm` content, and explicitly defined `content-type` header.

(cherry picked from commit 778ef4e217)
2021-03-20 23:10:00 +01:00
Fabio Alessandrelli be9b0e0b73
[HTML5] Fix editor version numbering.
Should not write patch version when it's `0`.

(cherry picked from commit 60f2166c27)
2021-03-20 23:08:28 +01:00
Rafał Mikrut 6b6324441f
Allow to not optimize release build
(cherry picked from commit 0b298d201e)
2021-03-20 23:05:13 +01:00
bruvzg 15ff752737
Add "Replace existing signature" to the macOS export (enabled by default).
(cherry picked from commit 9e18fce943)
2021-03-18 22:31:09 +01:00
Fredia Huya-Kouadio 14e7f6fa7c Fix onMainRequestPermissionsResult callback for Android plugins. 2021-03-17 09:30:19 -07:00
Fredia Huya-Kouadio 864f4201b9
Enable doNotStrip when doing development/debugging within Android Studio
(cherry picked from commit 4380004176)
2021-03-17 15:17:02 +01:00
Fredia Huya-Kouadio 94df08aae1 Leverage java annotations to simplify the logic used to register the Godot plugin methods. 2021-03-16 01:20:43 -07:00
Alex Hirsch 5a882a659a
Add parameter checkes to FileAccess get_buffer functions
fix #46540

(cherry picked from commit cdf3099c68)
2021-03-14 12:03:22 +01:00
Andrii Doroshenko (Xrayez) 7c7f4602e7
Add use_asan option for MSVC to enable AddressSanitizer
Exposes AddressSanitizer support in MSVC compiler. Can be installed via individual
components in the Visual Studio 2019 Installer.

Disabled by default. Compile the engine with `scons use_asan=yes`.

(cherry picked from commit 53901d870b)
2021-03-13 22:10:15 +01:00
Ev1lbl0w a586f9daae
Replace malloc's with Godot's memalloc macro
(cherry picked from commit 838e7d0a8d)
2021-03-13 22:01:27 +01:00
Fabio Alessandrelli 64feaed39b [HTML5] Drag and drop zip in project manager.
With a very nice hack, a new hidden configuration option that delays
dropped files removal at exit.

This still leaks while the project manager is running, but will clear
memory as soon as it exits or load something.
(reminder, dropped files are reguarly removed after the signal is
emitted specifically to avoid leaks, but I prefer hacking the HTML5
config then the project manager).

(cherry picked from commit f1e810adcb)
2021-03-12 10:43:52 +01:00
Fabio Alessandrelli 82b900bdda [HTML5] Properly set canvas size during setup.
It used to be updated before the first iteration, causing the
window/viewport size values to be incorrect during the initialization
phase (e.g. during the first `_ready` notification).

(cherry picked from commit 3f059b90d6)
2021-03-12 10:13:08 +01:00
Fabio Alessandrelli 4b38aefd33 [HTML5] Opt-in virtual keyboard support.
Added as an export option "Experimental Virtual Keyboard".
There is no zoom, so text/line edit must be in the top part of the
screen, or it will get hidden by the virtual keyboard.
UTF8/Latin-1 only (I think regular UTF-8 should work out of the box in
4.0 but I can't test it).
It uses an hidden textarea or input, based on the multiline variable,
and only gets activated if the device has a touchscreen.
This could cause problems on devices with both touchscreen and a real
keyboard (although input should still work in general with some minor
focus issues). I'm thinking of a system to detect the first physical
keystroke and disable it in case, but it might do more harm then good,
so it must be well thought.
2021-03-11 20:58:09 +01:00
Fabio Alessandrelli 758daab3ad [HTML5] Respect allow_hidpi option during setup
The option was forced to `true` before, unlike on other platforms.
2021-03-08 23:35:10 +01:00
Rémi Verschelde fd5966af64
Merge pull request #46797 from Faless/js/3.x_pwa_simple
[3.2][HTML5] Add PWA support to the editor page.
2021-03-08 17:29:57 +01:00
Fabio Alessandrelli d942d553ef [HTML5] Add PWA support to the editor page.
This allows to install it as an app, and provide offline support (after
the first run).
Practically, this boils down to adding a JSON file as a manifest, an
offline page to be displayed when the cached files are not avaialble,
and a JS file to cache resources and return them.

The reason for the "first run requirements" is that some browsers, will
emit an "install" by just visiting the page (to see if the JS code is
compatibile), and we do not want to force casual visitors to just
download the 10 MiB+ compressed editor WebAssembly file without pressing
the start button.

Special thanks to Hugo Locurcio (Calinou) for the initial work.
2021-03-08 17:06:41 +01:00
Fabio Alessandrelli 9028b7a095 [HTML5] Catch audio worklet errors on disconnect.
Which could happen if the worklet was not fully loaded, or the audio
context had already aborted.
2021-03-08 17:06:41 +01:00
Rémi Verschelde 03dda90ddd Linux: Fix PRIME detection on Steam
To avoid trying to do PRIME detection on fake `libGL.so` as used by e.g.
Renderdoc or Primus, we skip detection if there's a `libGL.so` in
`LD_LIBRARY_PATH`... and our luck is that Steam defines it and includes
system paths too, thus the actual system `libGL`... 🤦

So if we detect Steam, we skip this check.

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>

(cherry picked from commit 562b1cd2cda2098e62c7501dae87393def99c23a)
2021-03-08 16:03:24 +01:00
Fabio Alessandrelli c01f35de12 [HTML5] Replace XMLHttpRequest with Fetch.
This has some advantages:
- Streaming/chunked response support.
- Broader headers support.
2021-03-06 11:44:43 +01:00
Fabio Alessandrelli 751a6f9a63 [HTML5] Rename heapCopy to heapSlice.
New heapCopy function copies a TypedArray to the heap.
2021-03-05 17:32:17 +01:00