Safari failing to display Arc on 2D context

When attempting to draw a simple circle on a canvas, everything works smoothly in Chrome but encounters issues in Safari.

What's puzzling is that even though I can retrieve the x position of the circle as expected, it simply fails to render correctly.

canvas.context.beginPath();
canvas.context.strokeStyle = 'rgba(255, 153, 0, 1)';
canvas.context.lineWidth = 10;
canvas.context.arc(x, y, radius, 0, Math.PI * 2);
canvas.context.stroke();
canvas.context.closePath();

The custom variables width, height, and radius are dynamically calculated during runtime, with sample values being:

x = 155;
y = 155; 
radius = 25.5;

However, these values are subject to change within a certain range.

This code successfully displays an orange circle in Chrome, yet remains invisible in Safari. Any insights into why this discrepancy occurs?

Answer №1

After much troubleshooting, I finally uncovered a solution to my problem. It turns out that the issue stemmed from the fact that the radius was being calculated as a floating point number. Strangely enough, Safari was refusing to render an arc with a radius of 25.5. To work around this issue, I had to use

Math.floor(radius)

This simple adjustment resolved my problem. Although I am still unsure of the underlying cause, I wanted to share this solution in case anyone else encounters a similar obstacle.

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

What is the best way to implement caching for an autosuggest feature in a component

I am currently working on a UI autosuggest feature that triggers an AJAX request while the user is typing. For example, if the user types mel, the response may include suggestions for cities like Melbourne, East Melbourne, and North Melbourne. { suggest ...

Shifting an element to the right before revealing or concealing it with Jquery Show/Hide

$(document).ready(function(){ var speed = 700; var pause = 3500; function removeFirstElement(){ $('ul#newsfeed li:first').hide('slide', {direction: "up"}, speed, function() {addLastElement(thi ...

Updating Bootstrap 5.3 Modal to Have a Fixed Backdrop when Opened (Using JavaScript/JQuery)

Is there a way to change the backdrop of an open modal to 'static' using jQuery or JavaScript? I want to prevent the user from closing the modal by clicking outside after they have clicked the 'Submit' button on the modal. I've tri ...

"Exploring the power of Vue3's composition API in managing the

Trying to implement an accordion component in Vue 3, but encountering a strange comparison issue. I'm attempting to execute a function within the accordionitem - specifically the toggle operation. However, despite numerous attempts, I am unable to mo ...

Creating a promise class in JavaScript

I am in the process of creating a simple promise class with chainable .then() functionality in javascript. Here is my progress so far: class APromise { constructor(Fn) { this.value = null; Fn(resolved => { this.value = resolved; }); ...

Create a program that continues to run even if the user decides to close the window

Currently, I am in the process of developing a React project. There is a requirement for a function to continuously retrieve data using a web socket every second. However, I am faced with the challenge of ensuring that this function with the web socket s ...

Unfulfilled commitment on bcrypt

I am currently facing an issue while trying to validate a user's password using bcryptjs. I have implemented a function that returns a Promise, but I am encountering an error when reaching the bycrypt.hash step - all I see is Promise { <pending> ...

What occurs if the user navigates away from the page before the AJAX call has finished?

In my app, I use an asynchronous AJAX call for each page that loads in order to track a user's flow through the application. Usually, the server request to record the visit happens quickly. However, there are instances where I seem to be missing some ...

I'm having trouble pulling images from Firebase into my Vue application

Currently, I am experimenting with a Vue application that requires users to upload an image to Firebase. After the image is successfully uploaded, it should be displayed within an img tag in the template. The issue I am encountering is retrieving the uplo ...

Node.js: retrieving a webpage and waiting for it to load before extracting data

Is it possible to scrape a webpage using just node.js without relying on other libraries like phantom.js? That is the question I have been pondering lately. In my code below, I am requesting a webpage with request and then using cheerio to extract data by ...

The element 'flat' is not found within the specified type

My challenge involves utilizing the flat() method in a TypeScript script. In my tsconfig.json file, I have set the target to es2017 and defined an interface for the input variable. However, I keep encountering this error message: Property 'flat' ...

There was an issue with Angular 2.0 at :0:0, which was caused by a response with status: 0 from the URL: null

I am a beginner in Angular 2.0 and I am currently working on creating a sample application using @angular\cli. To serve the application on my local machine, I use the command ng serve --open, which opens it at localhost:4200. Now, I have developed a ...

A static method written in Typescript within an abstract class for generating a new instance of the class itself

Imagine I have abstract class Foo { } class Bar1 extends Foo { constructor(someVar) { ... } } class Bar2 extends Foo { constructor(someVar) { ... } } I want to create a static method that generates an instance of the final class (all construct ...

Unable to submit text when maximum characters reached in UITextField due to malfunctioning Done button on keyboard

To restrict the number of characters allowed in my textfield, I am using the following code: func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool { let newLength = (textField.t ...

The task of mapping an array of objects with nested values using JavaScript is proving to

Attempting to convert an array of objects with nested values in child objects like: const objs = [{ "B": { "value": 1, }, "D": { "value": "45" }, "E": { "value": "234" }, ...

Looking to retrieve the full browser URL in Next.js using getServerSideProps? Here's how to do

In my current environment, I am at http://localhost:3000/, but once in production, I will be at a different URL like http://example.com/. How can I retrieve the full browser URL within getServerSideProps? I need to fetch either http://localhost:3000/ or ...

Ways to apply the strategy pattern in Vue component implementation

Here's the scenario: I possess a Cat, Dog, and Horse, all of which abide by the Animal interface. Compact components exist for each one - DogComponent, CatComponent, and HorseComponent. Query: How can I develop an AnimalComponent that is capable of ...

Server side processes automatically converting boolean parameters in Axios get requests to strings

My code involves a JSON object being passed as parameters to the Axios GET API. Here is the JSON object: obj = { name: "device" value: true, } The Axios GET request is made with the above object like this - tableFilter = (obj) => { ...

tips on transferring information to Tbxml on an iPhone

I am currently experimenting with TBXML in an attempt to parse XML data using a username and password, but I'm unsure of the process. I have reviewed several tutorials but still need guidance. -(IBAction)login{ NSString* username ...

Tips for toggling the appearance of like and add to cart icons

I am attempting to create a simple functionality for liking and adding items to a cart by clicking on the icons, which should immediately change the icon's color when clicked. However, I am facing an issue where the parent div's link is also bein ...