Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flame_tiled] Null check on tileData fails for infinite maps #2855

Open
benni-tec opened this issue Nov 16, 2023 · 1 comment
Open

[flame_tiled] Null check on tileData fails for infinite maps #2855

benni-tec opened this issue Nov 16, 2023 · 1 comment
Assignees
Labels

Comments

@benni-tec
Copy link

Current bug behavior

A null check operator exception is thrown when trying to load (cache) infinite tiled maps

Expected behavior

The map is loaded in chunks or the chunks are consoladated

Steps to reproduce

Simply use an infinite map.

Flutter doctor output

[√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [Version 10.0.22621.2428], locale de-DE)
    • Flutter version 3.13.9 on channel stable at C:\Users\xxxxx\Coding\_sdks\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d211f42860 (3 weeks ago), 2023-10-25 13:42:25 -0700
    • Engine revision 0545f8705d
    • Dart version 3.1.5
    • DevTools version 2.25.0

[√] Windows Version (Installed version of Windows is version 10 or higher)

[X] Android toolchain - develop for Android devices
    X Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.5)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.7.34202.233
    • Windows 10 SDK version 10.0.22621.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).

[√] IntelliJ IDEA Ultimate Edition (version 2023.2)
    • IntelliJ at C:\Users\xxxxx\AppData\Local\Programs\IntelliJ IDEA Ultimate
    • Flutter plugin version 76.2.4
    • Dart plugin version 232.10072.19

[√] VS Code (version 1.84.0)
    • VS Code at C:\Users\xxxx\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
       https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.22621.2428]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 119.0.6045.124
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 119.0.2151.58

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.

More environment information

  • Flame version: 1.2.0
  • flame_tiled version: 1.14.1
  • Platform affected: all

Log information

ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Null check operator used on a null value
#0      OrthogonalTileLayer.cacheTiles (package:flame_tiled/src/renderable_layers/tile_layers/orthogonal_tile_layer.dart:25:36)
#1      FlameTileLayer.refreshCache (package:flame_tiled/src/renderable_layers/tile_layers/tile_layer.dart:181:5)
#2      RenderableTiledMap._refreshCache (package:flame_tiled/src/renderable_tile_map.dart:365:13)
#3      new RenderableTiledMap (package:flame_tiled/src/renderable_tile_map.dart:64:5)
#4      RenderableTiledMap.fromTiledMap (package:flame_tiled/src/renderable_tile_map.dart:300:12)

More information

This bug is caused because (as far as I can see all) FlameTileLayer's force-unwrap layer.tileData however with the current tiled implementation this can be null if the map is infinite and therefore split into chunks.

I see two possible solutions:

  1. Aggregate all chunks into a single matrix (this would be sufficient for my use case) however with very large maps this can lead to performance issues
  2. Implement some mechanism to only render visible chunks and scope the cache/rendering appropriately. This seems like it would require quite a lot of work.

Since finite maps are fine for my use case I probably won't be able to contribute a PR to this!
For the time being I think a warning in the docs that infinite maps are not support would be appropriate!
(I didn't find one so far, I hope I didn't miss it 😅)

@benni-tec benni-tec added the bug label Nov 16, 2023
@ufrshubham
Copy link
Collaborator

Yeah, probably the quickest way to avoid confusion on user side will be to add an assert for infinite maps.

@ufrshubham ufrshubham self-assigned this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants