Skip to content

Windows app crashes when using .ceil() after update #138693

Description

@krll-kov
AnyDesk_as9FKEfHIi.mp4
  int _scale(double source, double factor) {
    MessageBox(0, TEXT("CALLED!"), TEXT("TEST"), MB_OK);
    MessageBox(0, TEXT("No ceil: ${source * factor}!"), TEXT("TEST"), MB_OK);
    return (source * factor).ceil();
  }
  
  
  MessageBox(0, TEXT("sf: $scaleFactor"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("sc: $scale"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("width: ${appWindowSize.width}"), TEXT("TEST"), MB_OK);
  MessageBox(0, TEXT("height: ${appWindowSize.height}"), TEXT("TEST"), MB_OK);

  // Calculate the approptiate size of the window
  int normalWidth = 0;
  int normalHeight = 0;
  try {
     normalWidth = _scale(appWindowSize.width, scaleFactor * scale);
     MessageBox(0, TEXT("1dwada"), TEXT("TEST"), MB_OK);
     normalHeight = _scale(appWindowSize.height, scaleFactor * scale);
  } catch (_) {
    MessageBox(0, TEXT("$_"), TEXT("ERROR"), MB_OK);
  }

This started to happen since the latest Flutter 3.16.0 update.

If i remove .ceil(), there will be no crash, for some reason this happens not on all computers, but many users report to me that app is simply not launched because of this error. As soon as i change .ceil() to .toInt() problem disappears

PlatformDispatcher.instance.onError, try catch, FlutterError.onError, runZonedGuarded do not catch any errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopc: fatal crashCrashes that terminate the processdependency: dartDart team may need to help usdependency:dart-triagedTriaged by Dart teame: device-specificOnly manifests on certain devicesplatform-windowsBuilding on or for Windows specificallyr: fixedIssue is closed as already fixed in a newer versionteam-windowsOwned by the Windows platform team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions