Call stack limit exceeded, please reduce the recursion depth

I have been working on a project where I need to download encrypted images and decrypt them using RNcryptor in a JavaScript web application, then display them within the HTML of my app. Everything is functioning perfectly except for when the images are larger in size, which causes the call stack to be exceeded.

Interestingly, this issue does not occur when transferring images between devices like the iPhone, but only happens when trying to send them to the web app. Specifically, I encounter this error with an iPhone 6+ device but not with any other devices.

Here is the function I am currently using to convert a byte array to a base64 string:

function encode(data)
{
    var str = String.fromCharCode.apply(null,data);
    return btoa(str).replace(/.{76}(?=.)/g,'$&\n');
}

I am wondering if there might be a more efficient way to convert the data without exceeding the call stack. Even if it sacrifices speed, I am open to exploring alternative approaches.

Answer №1

The issue specifically affecting the iPhone 6 (especially with images taken using its camera) is due to the file size being too large. This problem is less likely to occur on older models like the iPhone 5 or 4 due to lower picture quality.

To resolve this, I recommend resizing the image before it is encoded and stored in the database within your app.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Storing and Manipulating a JavaScript Object with Vuex: A New Perspective

Consider a hypothetical JavaScript object class like this: class Car { var engineTurnedOn = false; ... public turnEngineOn() { engineTurnedOn = true } } If I want to turn the engine on, should I create an action called 'turnEngineOn&ap ...

Is there a way to prevent users from selecting dates and times prior to today, as well as blocking out the hours of 9:00am

Users are required to select a date within the range of today's date and one month in the future, and a time between 9:00am and 9:00pm. How can I implement validation to ensure this? <div class="row"> <div class="col"> <label cl ...

Unable to get windw.location.href to function properly on local server

Having trouble with window.location.href not working for me :/ Everything is running on a localhost using "xampp" //javascript function 1 function onLogin() { window.location = "http://localhost:4000/deletetable"; console.log("running..."); con ...

Converting getUserMedia() audio to a .OGG file format using JavaScript

Currently working on an HTML5 project where I am in the process of converting an iOS app to a web-based application. As part of the content creation, there is an audio recording feature that I am trying to replicate using JavaScript without relying on plug ...

Guide to transmitting webcam feed from server to servlet

I am trying to display the webcam connected to my server in a servlet. I have come across suggestions to use getUserMedia();, however, this only captures the user's video webcam feed and not the server's. Is there a way to achieve this? My servl ...

Encrypting an array of floats using XOR in C language

I have been exploring different methods to encrypt a float-type array and then decode it using the same function. Despite researching various threads online, I have yet to find a satisfactory solution. One approach I attempted was casting the float-type p ...

Issue: Your current version of `create-react-app` is outdated, version 5.0.0 is behind the latest release (5.0.1)

I'm having trouble running create-react-app as the title suggests. The version I am currently running, `create-react-app` 5.0.0, is outdated compared to the latest release (5.0.1). Global installation of Create React App is no longer supported. To f ...

Do I need to include a mobileprovision file on my iPad in order to test the ipa file?

My iPad app is not installing on the client's device after sending them the IPA file. Should I also send the mobile provision file along with the IPA for testing purposes? ...

When executing JavaScript code, the file remains unchanged and does not alter the URL

I want my form to check a SQL database upon submission and execute a JavaScript file that captures the data into a constant. However, instead of running the JS script on the page as desired, it redirects to a new URL. Is there a way to ensure that the JS ...

Filtering through an array of objects based on two specific conditions

I am working with an array of objects, each containing properties like category name, categoryId, and a subcategory list which is an array. I need to filter the data based on both the name and values in the subcategory list. Here is a sample of my array: ...

Creating a smooth transition curve for moving the camera along the z-axis using JavaScript and Three.js技

I am venturing into the world of Three.js and facing a challenge. In the center of my scene, I have a rotating icosahedron. When I click a button, it should start rotating faster and the camera should move closer to make it appear larger. However, I am str ...

Learn how to retrieve a meta tag's content value and perform a subtraction operation

I need assistance in retrieving the value of the meta tag content and performing a subtraction operation on it. Could someone lend me a hand with this, please? The meta tag is structured as follows: <meta itemprop="price" content="1699"> I ha ...

Navigating to the line that triggered the error in xcode

While using xcode 10 beta, I have been encountering common errors that occur when there is no data available or when unwrapping optionals. But how can I easily navigate to the specific line of code that caused the error, determine which array is out of ind ...

Utilizing Promise chains within React for making REST API requests

I am currently working on a React application and I am relatively new to React, so I would appreciate some guidance in the right direction. My application involves building components that rely on making various Rest API calls to fetch the necessary data ...

A step-by-step guide on incorporating a session variable from a for loop into an Onclick Javascript event and sending it via ajax

Apologies for the unclear title, my situation is a bit complex and I'm struggling to explain it correctly. The scenario is illustrated with an image. 1.) I have a while loop processing JSON data from PHP (which includes multiple user IDs). 2.) Ajax ...

What is the best way to display data in the view using Angular 5 by utilizing models, classes, or interfaces?

I am facing an issue while trying to display the data fetched from my backend. I have created a class to handle the data: When I request the User by ID URI, the returned data looks like this: https://i.sstatic.net/76BSY.jpg Similarly, when I request all ...

Problem with React-bootstrap Date and Time Picker

I am currently part of a Project team that is in need of a date-time picker component for our react application. We have been utilizing the following one: https://github.com/quri/react-bootstrap-datetimepicker However, we encountered an issue with it, de ...

The selection elements fail to reset correctly

I'm currently working on an Angular 4 application where I have a form that includes a select element inside a box. <div class="form-group"> <label for="designation">Designation</label> <select [class.red-borde ...

Creating a NestJs CASL Authorization guard that utilizes user attributes and policies for access control

I am currently working on implementing a generic policy-based guard in NestJS and CASL for list/get endpoints. I have been referring to the documentation available at https://docs.nestjs.com/security/authorization#integrating-casl. In this implementation, ...

Tips for preventing multiple button clicks until the completion of the initial click event

I created a clock that tells the time every quarter as per the professor's request. However, there is an issue - when I click multiple times, the clock keeps telling the time repeatedly until the number of tellings matches the number of clicks. I thou ...