Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
- **iOS downloads from a signed URL are saved (`VROPlatformDownloadURLToFile`, `VROPlatformDownloadURLToFileAsync`).** The temporary file was named after the URL's last path component with its query, and a signed URL's token pushed the name past the 255-byte file name limit, so the write failed and the download still reported success with a file that did not exist. `VROPlatformLastPathComponent` drops the query and fragment, and a failed write now fails the download.
- **Android: a camera added before the renderer no longer crashes (`VROPlatformUtil`, #597).** `libviro_renderer.so` now sets the `JavaVM` in `JNI_OnLoad`. It was set only when a renderer or loader started, and under Fabric `ViroARCamera`'s view is built first, so adding its node reached `getJNIEnv` with no VM.
- **A GLB whose skins share joints animates every skin (`VROGLTFLoader`, #599).** Resampling runs once per skin and rewrote a shared joint's channels in place; the next skin's pass kept only the translation of the merged channel, so those joints lost their rotation and scale. Every property of a channel is now copied.
- **A long polyline no longer overflows the stack (`VROPolyline`, `VROPolygon`).** `buildElement` built its index list as a variable-length array on the stack. The world mesh's debug drawing (`debugDrawEnabled`) on an accumulated mesh reaches hundreds of thousands of line corners, which overflowed the iOS main thread's stack and crashed the app. The list is on the heap now, as is a polygon's.

### Removed

Expand Down
10 changes: 6 additions & 4 deletions ViroRenderer/VROPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include "VROPolygon.h"
#include <vector>
#include "VROData.h"
#include "VROGeometryUtil.h"
#include "VROGeometrySource.h"
Expand Down Expand Up @@ -189,12 +190,13 @@ void VROPolygon::buildGeometry(std::vector<std::shared_ptr<VROGeometrySource>> &
}

std::shared_ptr<VROGeometryElement> VROPolygon::buildElement(size_t numCorners) {
int indices[numCorners];
for (int i = 0; i < numCorners; i++) {
indices[i] = i;
// On the heap: the corner count has no bound, so a stack array could overflow.
std::vector<int> indices(numCorners);
for (size_t i = 0; i < numCorners; i++) {
indices[i] = (int) i;
}

std::shared_ptr<VROData> indexData = std::make_shared<VROData>((void *) indices, sizeof(int) * numCorners);
std::shared_ptr<VROData> indexData = std::make_shared<VROData>((void *) indices.data(), sizeof(int) * numCorners);
std::shared_ptr<VROGeometryElement> element= std::make_shared<VROGeometryElement>(indexData,
VROGeometryPrimitiveType::Triangle,
VROGeometryUtilGetPrimitiveCount((int) numCorners,
Expand Down
11 changes: 7 additions & 4 deletions ViroRenderer/VROPolyline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include <vector>
#include "VROPolyline.h"
#include "VROLog.h"
#include "VROByteBuffer.h"
Expand Down Expand Up @@ -211,12 +212,14 @@ void VROPolyline::buildGeometry(std::vector<std::vector<VROVector3f>> &paths,
}

std::shared_ptr<VROGeometryElement> VROPolyline::buildElement(size_t numCorners) {
int indices[numCorners];
for (int i = 0; i < numCorners; i++) {
indices[i] = i;
// On the heap: a world mesh's debug lines reach hundreds of thousands of corners,
// which overflowed the render thread's stack as a variable-length array.
std::vector<int> indices(numCorners);
for (size_t i = 0; i < numCorners; i++) {
indices[i] = (int) i;
}

std::shared_ptr<VROData> indexData = std::make_shared<VROData>((void *) indices, sizeof(int) * numCorners);
std::shared_ptr<VROData> indexData = std::make_shared<VROData>((void *) indices.data(), sizeof(int) * numCorners);
std::shared_ptr<VROGeometryElement> element = std::make_shared<VROGeometryElement>(indexData,
VROGeometryPrimitiveType::TriangleStrip,
VROGeometryUtilGetPrimitiveCount((int) numCorners, VROGeometryPrimitiveType::TriangleStrip),
Expand Down
Loading