WebGadget-Invalid Memory Access

Post bugreports for the Mac OSX version here
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

WebGadget-Invalid Memory Access

Post by WilliamL »

I've just discovered the webgadget and have a problem. I have a window based on the example 'The Worlds Smallest Browser' (can't find the link right now), in my large program, and it works fine if I resize or close the window but if I click anywhere in the web window then hit the close button (red dot) I get a Invalid Memory Access in the main event loop. If the program is compiled it just crashes.

I've re-created the error but maybe only on this link?

Code: Select all

EnableExplicit

Define event

#window1=1
#window2=2
#webgadget1=1

If OpenWindow(#window1, 0, 0,865,535, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) 
    ;WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "file://MacBkPro_SSD/Users/vering2/Apps_stuff/PB_examples/WebCamAddict.jpg")
    WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "https://finance.yahoo.com/quote/%5EIXIC/")
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename 
EndIf 

If OpenWindow(#window2, 10, 10,20,20, "blank window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) 
EndIf 

Repeat
     Event = WaitWindowEvent()
     
     Select Event
         Case #PB_Event_CloseWindow
            CloseWindow(#window1) : Debug"Close window"
        Case #PB_Event_SizeWindow
            If EventGadget()=#webgadget1
                ResizeGadget(#webgadget1,#PB_Ignore,#PB_Ignore,WindowWidth(#window1),WindowHeight(#window1))
            EndIf     
    EndSelect
ForEver
Worlds Smallest Web Browser (Mini Browser)
https://www.purebasic.com/documentation ... er.pb.html
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: WebGadget-Invalid Memory Access

Post by fsw »

I think the crash you are experiencing is not the WebGadget's fault.
In your code you close the Window, but never exit the event loop.
Your app never ends...

This works:

Code: Select all

EnableExplicit

Define event

#window1=1
#window2=2
#webgadget1=1

If OpenWindow(#window1, 0, 0,865,535, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) 
    ;WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "file://MacBkPro_SSD/Users/vering2/Apps_stuff/PB_examples/WebCamAddict.jpg")
    WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "https://finance.yahoo.com/quote/%5EIXIC/")
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename 
EndIf 

If OpenWindow(#window2, 10, 10,20,20, "blank window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) 
EndIf 

Repeat
     Event = WaitWindowEvent()
     
     Select Event
        ;Case #PB_Event_CloseWindow
        ;    CloseWindow(#window1) : Debug"Close window"
        Case #PB_Event_SizeWindow
            If EventGadget()=#webgadget1
                ResizeGadget(#webgadget1,#PB_Ignore,#PB_Ignore,WindowWidth(#window1),WindowHeight(#window1))
            EndIf     
    EndSelect
;ForEver
Until Event = #PB_Event_CloseWindow
Debug"Window closed"
In this case, the event loop ends when the window is closed.
Therefore, the app ends as well.

I am to provide the public with beneficial shocks.
Alfred Hitshock
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: WebGadget-Invalid Memory Access

Post by WilliamL »

Thanks for the comment fsw,

I've modified my code so it will end but it still crashes if I select any text in the web window.

Code: Select all

EnableExplicit

Define event

#window1=1
#window2=2
#webgadget1=1

If OpenWindow(#window1, 0, 0,865,535, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) 
    ;WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "file://MacBkPro_SSD/Users/vering2/Apps_stuff/PB_examples/WebCamAddict.jpg")
    WebGadget(#webgadget1, 0, 0,WindowWidth(#window1),WindowHeight(#window1), "https://finance.yahoo.com/quote/%5EIXIC/")
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename 
EndIf 

If OpenWindow(#window2, 10, 10,80,80, "blank window", #PB_Window_SystemMenu | #PB_Window_SizeGadget) 
EndIf 

Repeat
     Event = WaitWindowEvent()
     
     Select Event
     Case #PB_Event_CloseWindow
         If EventWindow()=#window2 : End
             Else
                 CloseWindow(#window1) : Debug"Close window"
             EndIf   
    EndSelect
ForEver
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
User avatar
fsw
Addict
Addict
Posts: 1603
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: WebGadget-Invalid Memory Access

Post by fsw »

Tried your code, but I cannot make it crash.
I can click on any text (link) and the next website is opened.

Testing this on PB-6.11-LTS on macOS Sonoma 14.5 on MacBook Pro M1-MAX.
Xcode & Command Line Tools are current.

I am to provide the public with beneficial shocks.
Alfred Hitshock
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: WebGadget-Invalid Memory Access

Post by Fred »

I can't reproduce it here, can anybody else try it ?
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: WebGadget-Invalid Memory Access

Post by WilliamL »

Well, if I select any text in the window of my example, say the closing price then hit the close button I get the error.

But if I'm the only one then I would remove my bug report and assume I'm doing something wrong with my code.
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
User avatar
mk-soft
Always Here
Always Here
Posts: 6204
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: WebGadget-Invalid Memory Access

Post by mk-soft »

I can confirm your example with your link.
But it doesn't happen with every website.

This error does not occur with PB v6.11.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
WilliamL
Addict
Addict
Posts: 1252
Joined: Mon Aug 04, 2008 10:56 pm
Location: Seattle, USA

Re: WebGadget-Invalid Memory Access

Post by WilliamL »

Yes, I agree that it appears to be this website. Other websites work fine (like the PB document). I'm wondering if this site being interactive (you can move the graph etc) is the problem. Maybe it has it's own event loop that is activated when you click in the window.
MacBook Pro-M1 (2021), Sequoia 15.4, PB 6.20
Post Reply