The speed of the OpenLayers web application is significantly hindered when accessed from a mobile device using Android

Although it may seem like a common question that should be closed, I have reached a roadblock and cannot find a solution. I hope to provide enough details to make this question suitable for SO.

I am currently working on an OpenLayers web application that can be viewed here.

The source code can be found in this github repository.

When accessing the app from a computer, the user experience is smooth. However, when trying to access it from my mobile browser (Chrome on Google Pixel 2), it is extremely slow.

Specifically, there is a noticeable lag between touch interactions on the screen and the response of the application.

I attempted to use ChromeDevTools console to inspect the network console with my phone connected via USB, but could not determine the cause of this slowness.

Some key details:

  1. Using OpenLayers version 6.2.1
  2. Developed using TypeScript
  3. Bundled using parcel bundler for a dist folder
  4. Deploying built files on the server to serve the app

One thing I noticed is that the built files have unconventional names like src.9f4704d2.css.

This naming convention seems to be a result of using the parcel bundler when running npm run build.

I am unsure if this could be a contributing factor to the performance issue.

If anyone can provide insights or guidance on resolving this issue, I would greatly appreciate it. I can provide further details upon request, as I am uncertain where to look for a solution.


EDIT 1

Within my CSS, I am using @import rules. I came across a reference stating that

@import rules can be nested, causing the browser to load and parse each file in series.

While uncertain if this is the root cause, I will experiment by using multiple <link> tags to see if it improves performance...


EDIT 2

Replacing @import with multiple <link> tags did not resolve the issue.


EDIT 3 (POTENTIAL IDENTIFICATION OF THE ISSUE)

I have narrowed down the performance issue to the layers I am creating within the application.

My approach involves parsing three WMS URLs, extracting individual layers, and adding new ImageLayer with ImageWMS sources for each to the map.

To address the lag, I switched to using TileImage and TileWMS instead of ImageLayer and ImageWMS.

Despite this adjustment, the issue persisted.

I then experimented with using a single URL, adding only three layers in total to the map, resulting in improved performance.

It seems the key focus should be on the best strategy for adding layers to the map: utilizing one ImageWMS with all WMS layers at once or one ImageWMS per layer.

While the current approach allows for easy layer toggling, a unified ImageWMS setup may offer faster performance.

Are there any alternative strategies that I may have overlooked?

Answer №1

For optimal performance, consider implementing the viewport meta tag on your website.
Here's an example:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

This will help control page size and prevent unwanted resizing of the entire page. Additionally, it can help reduce the page size and optimize pixel handling within the viewport.

To further enhance your mobile web application, explore the use of meta tags specific to mobile web apps, such as the web-app-capable tag.

Consider using a fixed position for elements like maps and menu bars (as well as any elements that may overlap with the map) to improve rendering performance.

Another tip is to utilize TileWMS: this will cache tiles and only request new ones when needed. Additionally, consider the hdpi option in layer definitions for higher quality images, although this may increase canvas size and drawing operations. Experiment with this option to find the right balance for your needs.

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

Wireless Connection Directly between Android Smartphone and Other Devices

Looking to set up a direct communication link (via WiFi) between an Android device and another non-Android device that has WiFi capability implemented using C++. While Android offers direct WiFi for communication between two Android devices, how can I ac ...

What exactly are the implications of having dual type declarations in TypeScript?

I recently came across the Angular tutorial here In the code snippet below, there are double type declarations that I am having trouble understanding. handleError<T>(operation = 'operation', result?: T) { return (error: any): Observabl ...

What is the best way to combine two JSON arrays in an Android application?

After receiving a JSON response structured as follows : [{"ProjectID":1,"ProjectName":"Test","UserID":[1,3,5,7],"RSID":[2,4,6,8]}] I want to transform it into the following format : [{"ProjectID":1,"ProjectName":"Test","RS":[{"UserID":1,"RSID":2},{"User ...

Tips on preventing the need for null or undefined checks in JS/Typescript singletons that have an initialization function

Is there a way to streamline the process of handling props in an Object literal that is dynamically initialized only once? I'm looking for a pattern that would eliminate the need for repetitive null/undefined checks and throw errors when certain metho ...

I am having trouble figuring out the issue with the state and how to properly implement it in Typescript

I am having difficulties sending emails using Nodemailer, TypeScript, and NextJS. The contact.tsx file within the state component is causing errors when using setform. As a beginner in TypeScript, I have been unable to find a solution to this issue. Any he ...

Exploring Best Practices for Coding in node.js

Method 1: Constructor and Prototype Objects function Database(url) { this.url = url; } Database.prototype.info = function (callback) { http.get(this.url + '/info', callback); }; Method 2: Closures Approach function Database(url) { ...

The 'ReactNode' binding element is automatically assigned an 'any' type

Just started a new project using create-react-app app --template typescript. In the src/components/MyButton/MyButton.tsx file, I have the following code: import React, { ReactNode } from "react"; const MyButton = ({ children: ReactNode }) => ...

Using parameters to create unions in TypeScript

Is there a standard method to parametrically define a union? I'm searching for a way to generically define something like: type U<K> = T<K1> | T<K2> | ... | T<Kn> // Where K === (K1 | ... | Kn) Note: I'm encountering a s ...

Modify the colors specified in colors.xml from styles.xml

I have set custom colors in my colors.xml file as shown below. I am wondering if it's possible to update these colors in my styles.xml theme node. colors.xml <resources> <color name="themeBackground">#000000</color> <col ...

Displaying errors from an API using Angular Material mat-error

I am currently working on a form that includes an email field. Upon saving the form, the onRegisterFormSubmit function is called. Within this function, I handle errors returned by the API - specifically setting errors in the email form control and retrie ...

tsconfig is overlooking the specified "paths" in my Vue project configuration

Despite seeing this issue multiple times, I am facing a problem with my "paths" object not working as expected. Originally, it was set up like this: "paths": { "@/*": ["src/*"] }, I made updates to it and now it looks like ...

What is the importance of adding the ".js" extension when importing a custom module in Typescript?

This is a basic test involving async/await, where I have created a module with a simple class to handle delays mymodule.ts: export class foo { public async delay(t: number) { console.log("returning promise"); ...

Sending returned values from a promise to the calling function in Angular

I have a created a promise to retrieve values from a service and then assign them to variables trans and confidence, which should be used as transcript and conf in the save_data function. How can I return these values to the calling function and ensure tha ...

Fragment dynamically created layout area experiencing unresponsive touch in ViewPager

I am currently working on implementing a Viewpager with a calendar feature. To test the functionality of the ViewPager, I am using three instances of the calendar Fragment. When swiping between fragments, which we'll refer to as "SWIPING," I noticed t ...

Exploring ways to expand the theme.mixins feature in MUI 5

Currently, I am in the process of updating Material UI from version 4 to 5 and encountering challenges with my existing theming. Since we are using typescript, it is important to include the appropriate types when extending themes. I intend to include th ...

Android app encountering Volley throwing JsonPars exception

Hey there! I am a beginner in Android development and I'm trying to get some practice with Volley. Below is a code sample that I wrote: RequestQueue rq = Volley.newRequestQueue(this); String urlStr="https://api.github.com/users/mralexgray/repos"; ...

The error message "Property 'DecalGeometry' is not found in the type 'typeof "..node_modules/@types/three/index"'."

Within my Angular6 application, I am utilizing 'three.js' and 'three-decal-geometry'. Here is a snippet of the necessary imports: import * as THREE from 'three'; import * as OBJLoader from 'three-obj-loader'; import ...

Getting environment variables on the client side in Next.js: A step-by-step guide

How can I retrieve an environment variable in my Next.js application and pass the data into datadogRum.init? // _app.tsx import React from "react"; import { useEffect } from "react"; import type { AppProps } from "next/app"; ...

Error in Vue 3 Script Setup with Typescript: Implicit 'any' type for parameter 'el' in Template ref

Could someone help explain why I am receiving an error from TypeScript that says the following? error TS7006: Parameter 'el' implicitly has an 'any' type. ref="(el) => saveRef(index, el)". I am confident that the correct type is set ...

How can I combine my two ngIf conditions into an ngIf else statement?

Having trouble incorporating an *ngIf else with two large <div> elements, as the content seems overwhelming to organize properly while following the documentation. Initially believed that using the same styling for two open text boxes, with one hidd ...