iOS Question Gif WebView - Debug Work - Release No

MarcoRome

Expert
Licensed User
Longtime User
Hi all.
I have this code:
B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: B4i TestGif
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 10
#End Region


'*** Develop
#CertificateFile: yyy
#ProvisionFile: xxx
'*** 

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page

    Private WebView1 As WebView
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Page1.Initialize("Page1")
'    Page1.Title = "Page 1"
'    Page1.RootPanel.Color = Colors.White

    Page1.RootPanel.LoadLayout("1")
    NavControl.ShowPage(Page1)
   
    'Full screen
    Nav.SetNavigationBarVisibleAnimated(False)
    Dim no As NativeObject = App
    no.RunMethod("setStatusBarHidden:animated:", Array(True, False))
    SetStatusBarStyleLight
   
    Sleep(2000)
    WebView1.LoadURL("file://" & File.Combine(File.DirAssets,$"anima1.html"$))
   
End Sub

Sub SetStatusBarStyleLight
    Dim no As NativeObject = App
    no.RunMethod("setStatusBarStyle:", Array(1))
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
   
End Sub

Private Sub Application_Background
   
End Sub

Work without problem in debug ( i see gif without problem ).
But NO gif is displayed in Release Mode.
Where i wrong ??
Here also example ( CLICK HERE ) , if you run in debug work, in release mode No.
Thank you
Marco
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is recommended to use WKWebView instead of WebView. Apple has deprecated WebView.

WKWebView.LoadURL should not be used with asset files (it is probably the same case with WebView). You will need to copy the files to File.DirTemp and then load them.

It works in debug mode because of the virtual assets feature which means that the files are not inside the real assets folder.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Thanks Erel

WKWebView.LoadURL should not be used with asset files (it is probably the same case with WebView)

Yes, same thing.
The only way to work ( release ) is:

B4X:
    Private WebView1 As WKWebView
    .....
    Dim linktoimage As String
    linktoimage = File.Combine(File.DirAssets,"animazione-xxx.gif")
    WebView1.LoadHtml("<html><head></head><body><img width=""100%"" height=""100%"" src=' " & linktoimage & " '></body></html>")
 
Last edited:
Upvote 0
Top