Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why Do Async JavaScript Functions Throw Errors in Release Mode Build?
Forum Updated to NodeBB v4.3 + New Features

Why Do Async JavaScript Functions Throw Errors in Release Mode Build?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 108 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MyNameIsQt
    wrote on 17 Mar 2025, 12:24 last edited by
    #1

    Hello,

    I am developing a Qt application using WebChannel to display HTML. While everything works fine in Debug mode, I am encountering errors in JavaScript async functions when building the application in Release mode.

    Problem Description:

    In Debug mode, async functions work correctly without any issues.
    However, when building in Release mode, errors appear in async functions.
    The error messages are typically related to syntax errors, such as "Expected token ;".
    Only async functions are affected—other code works fine.
    Example of Problematic Function:

    async function set_edit(_e) {
        var offset = {};
        offset['x'] = _e.target.offsetLeft;
        offset['y'] = _e.target.offsetTop;
        offset['offsetX'] = _e.offsetX;
        offset['offsetY'] = _e.offsetY;
        
        const ret = await parent.edit_text({
            "offset": offset,
            "pick": pick,
            "page": page,
            "canvas": canvas
        });
    
        if (ret === true) {
            this.hide();
        }
    };
    
    

    In this code, the async function set_edit throws errors in Release mode. Other functions do not have this problem.

    Additional Information:

    The same errors appear in various files, and when I delete certain files and rebuild, the errors shift to different locations.
    For example, another function handleImage also has the same issue:

    async function handleImage(status = false) {
        try {        
            var decodedString = await wpubManager.getImgObject();
            let page = await wpubManager.getPage();
    
            if (decodedString) {
                const point = await window.wpubManager.getImagePosJSON();
    
                currentX = point.x;
                currentY = point.y;
    
                preDrawCanvas(decodedString, currentX, currentY);
                resetZoom();
            } else {
                var indexedDBId = await wpubManager.getIndexedDBId();
                if (indexedDBId !== '') {
                    try {
                        const indexedImage = await fetchImageFromIndexedDB(indexedDBId, page);
                        if (indexedImage) {
                            preDrawCanvas(indexedImage, 0, 0);
                            resetZoom();
                        } else {
                            console.error("No image data found in IndexedDB for ID:", indexedDBId);
                        }
                    } catch (error) {
                        console.error("Error fetching image from IndexedDB:", error);
                    }
                } else {
                    console.error("No IndexedDB ID received from wpubManager.");
                }
            }
            selectElement.selectedIndex = page - 1;
            if (status) getCount();
        } catch (error) {
            console.error("Error in handleImage function:", error);
        }
    }
    
    

    Questions:

    Why do async functions throw errors only in Release mode?
    Could optimization settings be the cause of these issues? How can I resolve this?
    Are there any known bugs related to async functions in Qt when building in Release mode?
    I’ve already checked optimization settings and the build environment but still cannot solve the issue. If anyone has had similar experiences or knows how to fix this, your advice would be greatly appreciated.
    Thank you!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andrewphilip
      wrote on 17 Mar 2025, 14:28 last edited by
      #2
      This post is deleted!
      1 Reply Last reply
      0

      1/2

      17 Mar 2025, 12:24

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved