Skip to content

[Bug] Cloud JavaScript output omits the mobile viewport meta tag #5909

Description

@jsfan3

Summary

I generated a new project with the web Initializr and built its JavaScript port using the CN1 cloud build server. The returned entry page has no viewport meta tag. On a phone, the application appears as a scaled desktop page with very small text, instead of starting with a device-width viewport. The uploaded output is unchanged.

Minimal reproducer

Test URL: https://routinote.hopto.me/scrolling-test/.

I generated a new project using the web Initializr at https://start.codenameone.com/, retained its generated Hello World screen, and added only one SpanLabel containing long placeholder text. I then submitted it to the Codename One cloud build server for JavaScript compilation. This is not an offline/local JavaScript build. The downloaded MyAppName-js.zip was published unchanged: all 36 hosted files match the archive byte-for-byte.

The application is MyAppName (codename1.displayName=MyAppName). Its complete entry class is below; only the long string's source formatting has been wrapped for readability. No scrolling, toolbar, viewport or selection override is added.

MyAppName.java
package com.example.myapp;

import static com.codename1.ui.CN.*;

import com.codename1.components.SpanLabel;
import com.codename1.system.Lifecycle;
import com.codename1.ui.*;
import com.codename1.ui.layouts.*;
import com.codename1.io.*;
import com.codename1.ui.plaf.*;
import com.codename1.ui.util.Resources;

/**
 * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
 * of building native mobile applications using Java.
 */
public class MyAppName extends Lifecycle {
    @Override
    public void runApp() {
        Form hi = new Form("Hi World", BoxLayout.y());
        Button helloButton = new Button("Hello World");
        hi.add(helloButton);
        helloButton.addActionListener(e -> hello());
        hi.getToolbar().addMaterialCommandToSideMenu("Hello Command",
                FontImage.MATERIAL_CHECK, 4, e -> hello());
        hi.add(new SpanLabel(
                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. "
                + "Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus "
                + "mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa "
                + "quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, "
                + "rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. "
                + "Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend "
                + "tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem "
                + "ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius "
                + "laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur "
                + "ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget "
                + "condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam "
                + "nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt "
                + "tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci "
                + "eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales "
                + "sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc. Lorem ipsum "
                + "dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. "
                + "Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec "
                + "quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. "
                + "Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, "
                + "imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer "
                + "tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. "
                + "Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, "
                + "dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. "
                + "Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper "
                + "ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, "
                + "sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, "
                + "luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae "
                + "sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus "
                + "tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed "
                + "consequat, leo eget bibendum sodales, augue velit cursus nunc,"));
        hi.show();
    }

    private void hello() {
        Dialog.show("Hello Codename One", "Welcome to Codename One", "OK", null);
    }

}

Steps to reproduce

  1. Open https://routinote.hopto.me/scrolling-test/ in a mobile browser with its desktop-site option disabled.
  2. Observe the initial layout and text size.
  3. Inspect the downloaded/generated index.html: its head contains a charset declaration but no <meta name="viewport">.
  4. To reproduce generation independently, use the web Initializr and entry class above, submit a JavaScript build to the CN1 cloud build server, and serve the returned files without editing the HTML.

Expected and observed behavior

Expected: the generated HTML declares a device-width viewport so that mobile browsers can use the phone's available CSS width from the first layout.

Observed: no viewport declaration is emitted, and I see the page at desktop scale with small text on a phone.

Suggested generated metadata:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

This preserves browser zoom and does not impose a virtual-keyboard or scrolling policy. The MDN viewport reference explains how missing mobile viewport metadata can produce a wider virtual viewport that is then scaled down.

Codename One version

7.0.273 for both cn1.version and cn1.plugin.version in the Initializr project's POM. The cloud artifact contains the ParparVM JavaScript runtime; its cn1-version-numbers file contains 7dd4e7d08b3442d90959477ee52a5ae8c4361b29.

JDK version

JDK 17: both generated JAR manifests contain Build-Jdk-Spec: 17. The project uses the installed Microsoft OpenJDK 17.0.19 (ms-17 in IntelliJ), and its CN1 Java build hint is 17. The JavaScript compilation itself ran on the Codename One cloud build server.

Target environment

Target: the cloud-compiled JavaScript port served over HTTPS on a phone.
I identified the missing mobile layout in this fresh minimal example. I did not record the exact phone browser versions.
Build submission host: macOS 15.8 (24H23).

Last known working version

Unknown. My earlier web builds were responsive, but I have not identified a specific last-good build or first-bad release.

Logs and diagnostics

Static inspection of the unmodified cloud artifact:

index.html starts with:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Codename One JavaScript Port</title>
<link rel="stylesheet" href="style.css">

There is no meta[name="viewport"] in index.html.

Screenshots or recordings

No mobile screenshot is attached. The live minimal example and exact generated HTML omission are provided above.

Report checks

  • I searched existing issues and discussions for this behavior.
  • The reproducer contains no credentials, signing keys, or private customer data.
  • I understand that triage is not a commitment to a fix date.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions