Commit graph

2974 commits

Author SHA1 Message Date
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
Fabio Alessandrelli 41c64533b0 [HTML5] Export process writes sizes in template.
This allow the loading bar to be much more reliable, even in cases where
realible stream loading status is not detectable (server-side
compression, chunked encoding).
2021-03-05 17:32:17 +01:00
Fabio Alessandrelli f64ec5f1ad [HTML5] Preloader fetch, streaming instantiation. 2021-03-05 17:32:17 +01:00
Shane Liesegang 4d06a5c2b0 Mono/macOS: Separate data dir into frameworks and resources for codesigning
Co-authored-by: Ignacio Etcheverry <ignalfonsore@gmail.com>
(cherry picked from commit 42eb09ddcc)
2021-03-04 12:21:17 +01:00
Jordan Schidlowsky ced5f5398a add msan sanitizer option for linus/bsd, lsan option for osx
(cherry picked from commit da35cd2f00)
2021-03-04 11:33:35 +01:00
bruvzg 1c27d4a73d
[macOS] Add entitlements config and export template dylib signing to the export. 2021-03-03 12:40:44 +02:00
Ev1lbl0w be4e34b495
Prevent invalid values when resizing window (X11) 2021-03-01 12:22:16 +00:00
Pedro Rodrigues 66da113237 Fix out of bounds array access on OS_X11 code
The problem happened on methods `get_screen_position`, `get_screen_size`
and `set_current_screen` when they were passed a negative screen value.

Fixes:
- #46184
- #46185
- #46186
2021-02-28 17:20:04 +00:00
Rémi Verschelde 8385a0d8ad
Merge pull request #46458 from m4gr3d/fix_invalid_missing_templates_error
[3.2] Fix invalid missing template error when the Android build template is not installed
2021-02-27 16:52:41 +01:00
Fredia Huya-Kouadio 92d3287648 Fix invalid missing template error when the Android build template is not installed. 2021-02-26 12:28:19 -08:00
Fredia Huya-Kouadio c5fb32d594 Update the logic to load Godot Android plugins packaged into the binary.
The previous logic had the side effect of imposing a limit of one plugin per `aar` binary. The update lifts that restriction.
2021-02-26 09:09:40 -08:00
Fabio Alessandrelli 43e429fa93 [HTML5] Add jsdoc2rst tool.
A template for `jsdoc` that generat the HTML5 public classref.

The script can be run via `npm run docs` to print to stdout.

You can dry run via `npm run docs -- --d dry-run` or write to file via
`npm run docs -- -d /path/to/file.rst`

Also update Makefile in `doc/` and add dry run test to CI.

(cherry picked from commit 472482013e)
2021-02-26 15:35:45 +01:00
Fabio Alessandrelli 681c10af45 [HTML5] Document Engine and EngineConfig (jsdoc).
This commit also removes the utils.js engine file, moving some of it's
content to config.js and some to engine.js .

(cherry picked from commit 018ee5a4dc)
2021-02-26 15:35:38 +01:00
Fabio Alessandrelli e3664e971b [HTML5] Make editor HTML build tag scons4-proof.
We used to have it like `$GODOT_VERSION` which caused inconsistencies
between different scons versions when substituting it.
It's now `@GODOT_VERSION@`, which is safe on both scons3 and scons4.

(cherry picked from commit 4404eb57e4)
2021-02-26 15:22:51 +01:00
PouleyKetchoupp ea1d4256a4 Added LocalVector to Visual Studio debugger visualization
(cherry picked from commit 27d5e1fff0)
2021-02-25 15:14:32 +01:00
Fredia Huya-Kouadio 65eb5fdf1e Update the initialization timeline for the Godot fragment to be more consistent with the previous activity based timeline.
(cherry picked from commit 3ce7678374)
2021-02-25 15:14:32 +01:00
Fredia Huya-Kouadio 9fb5215db5 Add logic to record the version of the Godot engine for the Android platform.
(cherry picked from commit bc5120eb97)
2021-02-25 15:14:32 +01:00
Rémi Verschelde 693a27e9dd
Merge pull request #46336 from m4gr3d/fix_android_resources_inclusion
[3.2] Update the filtering logic to properly handle directories with `.gdignore` files
2021-02-25 14:15:19 +01:00
Hein-Pieter van Braam-Stewart 5f71fad6b6 Allow static linking with libatomic using clang
When using use_static_cpp we want to statically link with atomic as well
to make sure we don't incur any new runtime dependencies.

Scons doesn't quite support this so we do this little trick.
2021-02-23 14:48:51 +01:00
Fredia Huya-Kouadio 48108444f1 Update the filtering logic to properly handle directories with .gdignore files. 2021-02-22 20:18:56 -08:00
Hein-Pieter van Braam-Stewart 5ff172e34d Use -latomic when using clang (server platform)
version of c9b3a00a63 for the server
platform

(cherry picked from commit 6a146d405c)
2021-02-22 21:39:22 +01:00
Pedro J. Estébanez c75b3fedc4 Fix build error in UWP 2021-02-22 17:57:27 +01:00
Rémi Verschelde d1f023c35b SCons: Fix UWP build after #45618 2021-02-22 15:30:48 +01:00
Hein-Pieter van Braam f15f5b4578
Merge pull request #46242 from hpvb/dri-prime-amd
[3.2] Add 'AMD' GPU vendor name to PRIME detector
2021-02-20 17:19:04 +01:00
Hein-Pieter van Braam-Stewart 0cce213f14 Use -latomic when linking whe using clang on Linux
According to the LLVM documentation when using GNU's libstdc++ clang
will not automatically link with -latomic. This is necessary since we
merged c++11 atomics support.

This fixes linking using Clang on Linux
2021-02-20 16:37:00 +01:00
Hein-Pieter van Braam-Stewart 92687b4544 Add 'AMD' GPU vendor name to PRIME detector
Apparently some recent Mesa version also changed AMD's vendor string. In
addition I found a small uninitialized variable that's corrected now.
2021-02-20 02:03:05 +01:00
Rémi Verschelde 0d94bf707f
Merge pull request #46201 from Faless/js/3.x_canvas_size_pr
[3.2] [HTML5] Easier HTML templates, better canvas size handling.
2021-02-19 15:16:59 +01:00
Fabio Alessandrelli 45a67fab35 [HTML5] Better fullscreen, canvas resizing.
Three canvas resize policies:
- `None`: Godot window settings are ignored.
- `Project`: Godot handles the canvas like a native app (resizing it
  when setting the window size).
- `Adaptive`: Canvas size will always adapt to browser window size.

Use `None` if you want to control the canvas size with custom JavaScript
code.
2021-02-19 05:13:44 +01:00
Fabio Alessandrelli 1eef8a318b [HTML5] Easier HTML templates, better deinit/cleanup. 2021-02-19 05:13:44 +01:00
Hein-Pieter van Braam 220f24c191
Merge pull request #45618 from RandomShaper/modernize_mt_3.2
Backport of all the multi-threading modernization (3.2)
2021-02-18 20:47:24 +01:00
Fredia Huya-Kouadio ca6e1c1c45
Override ANDROID_NDK_ROOT based on the project ndk version.
This helps resolve issues where the project ndk version differs from the one pointed by the `ANDROID_NDK_ROOT` environment variable (if it exists).

(cherry picked from commit edeca16fb6)
2021-02-18 14:59:10 +01:00
Pedro J. Estébanez 4485b43a57 Modernize atomics
- Based on C++11's `atomic`
- Reworked `SafeRefCount` (based on the rewrite by @hpvb)
- Replaced free atomic functions by the new `SafeNumeric<T>`
- Replaced wrong cases of `volatile` by the new `SafeFlag`
- Platform-specific implementations no longer needed

Co-authored-by: Hein-Pieter van Braam-Stewart <hp@tmm.cx>
2021-02-18 12:23:25 +01:00
Fredia Huya-Kouadio ef9d945e16 Disable engine splash logic on Android; this is now handled by the Android theme api.
In addition, add support for scaling and applying filter to the splash screen on Android.
One limitation of the api being used is that the splash screen aspect ratio is not maintained when it's scaled up.
2021-02-18 03:17:58 -08:00
Pedro J. Estébanez 6d89f675b1 Modernize Thread
- Based on C++11's `thread` and `thread_local`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed (except for the few cases of non-portable functions)
- Simpler for `NO_THREADS`
- Thread ids are now the same across platforms (main is 1; others follow)
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez 8f6a636ae7 Modernize Semaphore
- Based on C++11's `mutex` and `condition_variable`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez 4ddcdc031b Modernize Mutex
- Based on C++11's `mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
- `BinaryMutex` added for special cases as the non-recursive version
- `MutexLock` now takes a reference. At this point the cases of null `Mutex`es are rare. If you ever need that, just don't use `MutexLock`.
- `ScopedMutexLock` is dropped and replaced by `MutexLock`, because they were pretty much the same.
2021-02-18 11:58:08 +01:00
Pedro J. Estébanez b450036120 Modernize RWLock
- Based on C++14's `shared_time_mutex`
- No more need to allocate-deallocate or check for null
- No pointer anymore, just a member variable
- Platform-specific implementations no longer needed
- Simpler for `NO_THREADS`
2021-02-18 11:41:07 +01:00
Fredia Huya-Kouadio 96a3f01ac5
Add missing ndkVersion to the library gradle build config.
(cherry picked from commit 9418197081)
2021-02-18 10:37:59 +01:00
Fredia Huya-Kouadio 1557bc8396
Revert AGP to version 4.0.1 as a workaround to https://issuetracker.google.com/issues/171235570 in version 4.1.x
(cherry picked from commit e5311f3523)
2021-02-18 10:37:28 +01:00
Rémi Verschelde ad7710ae5e
Dynamically load libudev.so.1 on Linux if udev=yes
This makes it possibly to run Linux binaries compiled with udev support on
Linux systems which do not provide udev (typically systemd-less distros).

If udev is missing, we fall back to parsing `/dev/input` like when compiled
without udev support (`udev=no`).

Also adding some verbose debug statements to know which method we're using
when debugging Linux joypad issues.

The libudev so wrappers were generated on Mageia 8 with libudev 246.9 using
https://github.com/hpvb/dynload-wrapper:
```
./generate-wrapper.py --include /usr/include/libudev.h --sys-include '<libudev.h>' \
  --soname libudev.so.1 --init-name libudev --omit-prefix gnu_ \
  --output-header libudev-so_wrap.h --output-implementation libudev-so_wrap.c
```

(cherry picked from commits a10c259c1d
and e26a1f807b)

Edit: Updated to version 0.2 of dynload-wrapper to fix symbols clobbering as
done in #46143.
2021-02-18 10:31:31 +01:00
Rémi Verschelde 48b73e4532
Android: Bump NDK version to 21.4.7075529
This is what GitHub Actions now provide and they removed the previous 21.3.6528147.
A bit annoying to have our hand forced this way but it's still 21.x so should be good
to upgrade.

(cherry picked from commit c730da8b20)
2021-02-18 00:36:46 +01:00
Quadtree a81f896ec1
Add cwrap to EXTRA_EXPORTED_RUNTIME_METHODS
(cherry picked from commit d2c34e83b5)
2021-02-18 00:35:57 +01:00