Results 1 to 4 of 4

Thread: in new Thread, report this error "ECannotCreateWICImagingFactory"

  1. #1

    in new Thread, report this error "ECannotCreateWICImagingFactory"

    Code:
    procedure TArchiveManager.loadImages(const pvPath: string);var
      lvFileList: TStrings;
      i: Integer;
      lvKey: string;
    begin
      lvFileList:= TStringList.Create;
      try
        enumFileInRecursion(pvPath,lvFileList,'.png');
        for i:= 0 to lvFileList.Count -1 do
        begin
          FLocker.lock();
          try
            lvKey:= ChangeFileExt(ExtractFileName(lvFileList[i]), '');
            FEngineImages.AddFromFile(lvFileList[i],lvKey);
          finally
            FLocker.unLock;
          end;
        end;
      finally
        lvFileList.Free;
      end;
    end;
    
    
    procedure onLoadGameData;
    begin
      gvArchiveManager.loadFiles('.\config','.aui,.amap',gvArchiveManager.FEngineConfigs);
      sleep(1000);
      gvArchiveManager.loadFiles('.\script','.lua',gvArchiveManager.FEngineScripts);
      sleep(1000);
      gvArchiveManager.loadFiles('.\sound','.ogg,.wav',gvArchiveManager.FEngineSounds);
      sleep(1000);
      gvArchiveManager.loadFonts('.\font');
      sleep(1000);
      gvArchiveManager.loadImages('.\artres');
    
    
      gvGameState:= tgsLoadingCompleted;
    end;
    
    
    procedure TArchiveManager.loadAll();
    begin
      TThread.CreateAnonymousThread(onLoadGameData).Start;
    end;

  2. #2
    onLoadGameData must call CoInitialize fix this error:
    {$IFDEF MSWINDOWS}CoInitialize(nil);{$ENDIF}

  3. #3
    Thanks for documenting this, but this is really how COM works when you use multi-threading, it doesn't look like something that can be done on PXL's side.

  4. #4
    Quote Originally Posted by LP View Post
    Thanks for documenting this, but this is really how COM works when you use multi-threading(Main Thread Load Images, not found this error), it doesn't look like something that can be done on PXL's side.
    Now,add "CoInitialize" and fixed "ECannotCreateWICImagingFactory". but, If use multi-threading, occasionally report new error "floating point divide by zero at 0x6be7464e". this error break to "FMX.Canvas.D2D.pas":

    Code:
    class function TBitmapCodecWIC.IsValid(const AStream: TStream): Boolean;
    var
      Decoder: IWICBitmapDecoder;
      Frame: IWICBitmapFrameDecode;
      W, H: UINT;
      CopyStream: TMemoryStream;
      Stream: IWICStream;
      SavePosition: Int64;
    begin
      W := 0;
      H := 0;
      SavePosition := AStream.Position;
      try
        CopyStream := TMemoryStream.Create;
        try
          CopyStream.CopyFrom(AStream, AStream.Size);
    
    
          ImagingFactory.CreateStream(Stream);
          Stream.InitializeFromMemory(CopyStream.Memory, CopyStream.Size);
    
    
          ImagingFactory.CreateDecoderFromStream(stream, GUID_NULL, WICDecodeMetadataCacheOnDemand, Decoder);
          if Decoder <> nil then
          begin
            Decoder.GetFrame(0, Frame);
            if Frame <> nil then
              Frame.GetSize(W, H);
          end;
          Result := W * H <> 0;
        finally
          CopyStream.Free;
        end;
      finally
        AStream.Position := SavePosition;
      end;
    end;
    Stack sequence:
    :6be7464e ; C:\Windows\SysWOW64\WindowsCodecs.dll
    :6bee8413 ; C:\Windows\SysWOW64\WindowsCodecs.dll
    :6bee747f ; C:\Windows\SysWOW64\WindowsCodecs.dll
    :6be1a070 ; C:\Windows\SysWOW64\WindowsCodecs.dll
    :6be1944e ; C:\Windows\SysWOW64\WindowsCodecs.dll
    :6be13f1a ; C:\Windows\SysWOW64\WindowsCodecs.dll
    FMX.Canvas.D2D.TBitmapCodecWIC.IsValid($26DB33
    FMX.Graphics.TBitmapCodecManager.LoadFromStream(,$C3DB6C0,0)
    PXL.FMBridge.TFMBridge.LoadFromStream(nil,'.png',$ 26DB338,$A857720,DontCare)
    PXL.ImageFormats.TImageFormatManager.LoadFromStrea m('.png',$26DB338,$A857720,DontCare)
    PXL.Images.TAtlasImage.LoadFromStream('.png',$26DB 338,DontCare)
    PXL.Images.TAtlasImages.AddFromStream('.png',$26DB 338,'item_e10050',True,DontCare,Unknown)
    PXL.Images.TAtlasImages.AddFromFile('.\artres\item _e10050.png','item_e10050',True,DontCare,Unknown)
    fol.client.archive.TFOLArchiveManager.loadImages(' .\artres')
    fol.client.archive.onLoadGameData

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •