Skip to content

Image.fromEncodedBytes fails in Krom target #35

@mundusnine

Description

@mundusnine

Expected Behavior

Get image files

Current Behavior

The bytes are loaded from haxe.Resources but when trying to get the Image object from kha we get crapped data. This seems to be caused by the Js engine that recycles the data before we get it back. Hence, we get data that is null.
Here is the output:

 Trace: TypeError: Cannot read property 'width' of null
    at $hxClasses.kha.Image.get_realWidth (<anonymous>:50598:30)
    at <anonymous>:8490:36
    at Function.kha_Image.fromEncodedBytes (<anonymous>:50448:2)
    at $hxClasses.haxe.ui.ToolkitAssets.imageFromBytes (<anonymous>:8489:13)
    at $hxClasses.haxe.ui.ToolkitAssets.getImageFromHaxeResource (<anonymous>:8484:8)
    at <anonymous>:8634:14
    at $hxClasses.haxe.ui.ToolkitAssets.getImageInternal (<anonymous>:8479:4)
    at $hxClasses.haxe.ui.ToolkitAssets.getImage (<anonymous>:8628:10)
    at $hxClasses.haxe.ui.util.ImageLoader.load (<anonymous>:31113:33)
    at $hxClasses.haxe.ui.components._Image.ResourceBehaviour.validateData (<anonymous>:14510:15)
Trace: TypeError: Cannot read property 'width' of null
    at $hxClasses.kha.Image.get_realWidth (<anonymous>:50598:30)
    at <anonymous>:8490:36
    at Function.kha_Image.fromEncodedBytes (<anonymous>:50448:2)
    at $hxClasses.haxe.ui.ToolkitAssets.imageFromBytes (<anonymous>:8489:13)
    at $hxClasses.haxe.ui.ToolkitAssets.getImageFromHaxeResource (<anonymous>:8484:8)
    at <anonymous>:8634:14
    at $hxClasses.haxe.ui.ToolkitAssets.getImageInternal (<anonymous>:8479:4)
    at $hxClasses.haxe.ui.ToolkitAssets.getImage (<anonymous>:8628:10)
    at $hxClasses.haxe.ui.util.ImageLoader.load (<anonymous>:31113:33)
    at $hxClasses.haxe.ui.components._Image.ResourceBehaviour.validateData (<anonymous>:14510:15)

Possible Solution

This pull request removes the issue in the short-term. In the long-term this issue needs to be investigated in Krom.

Steps to Reproduce (for bugs)

  1. Have a dialog be visible(the X to close the window is an image so you should crash)

Context

Have a dialog open

Your Environment

This issue happens only in

  • Version used: Git haxeui-core and haxeui-kha
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Krom
  • Operating System and version (desktop or mobile): Linux and Windows
  • Issue doesn't appear: In Kore app and html5

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