| View previous topic :: View next topic |
| Author |
Message |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Thu Aug 07, 2008 9:28 am Post subject: HTMLViewer in Homebrew |
|
|
I cannot for the life of me figure out how to load the internet browser in my program. I have gone over the htmlviewer sample in the SDK samples and i tried a few different ways to add it to my code but then i try to load the browser it just crashes. My code compiles fine so i have no idea what i did wrong.
If anyone has figured this out already help would be much appreciated :)
My Code:
browser.c
| Code: | #include <pspsdk.h>
#include <pspuser.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <psputility.h>
#include <psputility_netmodules.h>
#include <psputility_htmlviewer.h>
#include <pspnet.h>
#include <pspnet_inet.h>
#include <pspnet_apctl.h>
#include <pspnet_resolver.h>
#include <psphttp.h>
#include <pspssl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <sys/unistd.h>
#include "graphics.h"
void throwError(int milisecs, char *fmt, ...)
{
va_list list;
char msg[256];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
pspDebugScreenClear();
pspDebugScreenPrintf(msg);
sceKernelDelayThread(milisecs * 1000);
sceKernelExitGame();
}
void loadNetModules()
{
sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);
sceUtilityLoadNetModule(PSP_NET_MODULE_PARSEURI);
sceUtilityLoadNetModule(PSP_NET_MODULE_PARSEHTTP);
sceUtilityLoadNetModule(PSP_NET_MODULE_HTTP);
sceUtilityLoadNetModule(PSP_NET_MODULE_SSL);
}
void unloadNetModules()
{
sceUtilityUnloadNetModule(PSP_NET_MODULE_SSL);
sceUtilityUnloadNetModule(PSP_NET_MODULE_HTTP);
sceUtilityUnloadNetModule(PSP_NET_MODULE_PARSEHTTP);
sceUtilityUnloadNetModule(PSP_NET_MODULE_PARSEURI);
sceUtilityUnloadNetModule(PSP_NET_MODULE_INET);
sceUtilityUnloadNetModule(PSP_NET_MODULE_COMMON);
}
void netTerm()
{
sceHttpSaveSystemCookie();
sceHttpsEnd();
sceHttpEnd();
sceSslEnd();
sceNetApctlTerm();
sceNetInetTerm();
sceNetTerm();
unloadNetModules();
}
void netInit()
{
int res;
loadNetModules();
res = sceNetInit(0x20000, 0x2A, 0, 0x2A, 0);
if (res < 0)
{
throwError(6000, "Error 0x%08X in sceNetInit\n", res);
}
res = sceNetInetInit();
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceNetInetInit\n", res);
}
res = sceNetResolverInit();
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceNetResolverInit\n", res);
}
res = sceNetApctlInit(0x1800, 0x30);
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceNetApctlInit\n", res);
}
res = sceSslInit(0x28000);
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceSslInit\n", res);
}
res = sceHttpInit(0x25800);
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceHttpInit\n", res);
}
res = sceHttpsInit(0, 0, 0, 0);
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceHttpsInit\n", res);
}
res = sceHttpsLoadDefaultCert(0, 0);
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceHttpsLoadDefaultCert\n", res);
}
res = sceHttpLoadSystemCookie();
if (res < 0)
{
netTerm();
throwError(6000, "Error 0x%08X in sceHttpsLoadDefaultCert\n", res);
}
}
#define BROWSER_MEMORY (10*1024*1024)
SceUID vpl;
pspUtilityHtmlViewerParam params;
void htmlViewerInit(char *url)
{
int res;
vpl = sceKernelCreateVpl("BrowserVpl", PSP_MEMORY_PARTITION_USER, 0, BROWSER_MEMORY + 256, NULL);
if (vpl < 0)
throwError(6000, "Error 0x%08X creating vpl.\n", vpl);
memset(¶ms, 0, sizeof(pspUtilityHtmlViewerParam));
params.base.size = sizeof(pspUtilityHtmlViewerParam);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, ¶ms.base.language);
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, ¶ms.base.buttonSwap);
params.base.graphicsThread = 17;
params.base.accessThread = 19;
params.base.fontThread = 18;
params.base.soundThread = 16;
params.memsize = BROWSER_MEMORY;
params.initialurl = url;
params.numtabs = 1;
params.cookiemode = PSP_UTILITY_HTMLVIEWER_COOKIEMODE_DEFAULT;
params.homeurl = url;
params.textsize = PSP_UTILITY_HTMLVIEWER_TEXTSIZE_NORMAL;
params.displaymode = PSP_UTILITY_HTMLVIEWER_DISPLAYMODE_SMART_FIT;
params.options = PSP_UTILITY_HTMLVIEWER_DISABLE_STARTUP_LIMITS|PSP_UTILITY_HTMLVIEWER_ENABLE_FLASH;
params.interfacemode = PSP_UTILITY_HTMLVIEWER_INTERFACEMODE_FULL;
params.connectmode = PSP_UTILITY_HTMLVIEWER_CONNECTMODE_MANUAL_ALL;
// Note the lack of 'ms0:' on the paths
params.dldirname = "/PSP/PHOTO";
res = sceKernelAllocateVpl(vpl, params.memsize, ¶ms.memaddr, NULL);
if (res < 0)
throwError(6000, "Error 0x%08X allocating browser memory.\n", res);
res = sceUtilityHtmlViewerInitStart(¶ms);
if (res < 0)
throwError(6000, "Error 0x%08X initing browser.\n", res);
}
int updateHtmlViewer()
{
guStart();
switch (sceUtilityHtmlViewerGetStatus())
{
case PSP_UTILITY_DIALOG_VISIBLE:
sceUtilityHtmlViewerUpdate(1);
break;
case PSP_UTILITY_DIALOG_QUIT:
sceUtilityHtmlViewerShutdownStart();
break;
case PSP_UTILITY_DIALOG_NONE:
return 0;
break;
default:
break;
}
return 1;
}
void launchBrowser(void)
{
char url[] = "http://www.ps2dev.org/";
netInit();
htmlViewerInit(url);
while(updateHtmlViewer())
{
sceDisplayWaitVblankStart();
flipScreen();
}
netTerm();
sceKernelFreeVpl(vpl, params.memaddr);
sceKernelDeleteVpl(vpl);
}
|
browser.h
| Code: | #ifndef __BROWSER__
#define __BROWSER_H__
extern void launchBrowser(void);
#endif |
|
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Thu Aug 07, 2008 10:02 am Post subject: |
|
|
Hi Ooblik, welcome to the forums.
What heap size are you giving your program? |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Thu Aug 07, 2008 1:25 pm Post subject: |
|
|
PSP_HEAP_SIZE_MAX();
I also tested it on a Slim with PSP_LARGE_MEMORY = 1 in the Makefile to see if that would make any difference. Still just crashes... |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Aug 07, 2008 1:58 pm Post subject: |
|
|
| Probably BECAUSE of max... try not allocating all the memory to the heap. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Thu Aug 07, 2008 3:14 pm Post subject: |
|
|
| Still crashes when I set it lower.. hmm.. I think it might be something graphics related.. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Aug 07, 2008 4:53 pm Post subject: |
|
|
| You have the browser set to allocate 10 MB of memory... did you leave at least that much free? Lowering the memory heap from MAX to MAX-1MB won't allow the browser to allocate 10 MB. :) |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Thu Aug 07, 2008 10:41 pm Post subject: |
|
|
You need the 10MB for the VPL and you need around ~6MB of space free for the cache too.
PSP_HEAP_SIZE_MAX() is no good.
You can get away with allocating about 3MB for the VPL, but you still need 6MB of space free for the cache. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Fri Aug 08, 2008 4:14 am Post subject: |
|
|
| I've already said i tried setting the heap lower. So are you saying its not possible or what? If it is what should the heap be set too? |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Fri Aug 08, 2008 4:37 am Post subject: |
|
|
Give the VPL 4MB.
Set your heap size to 8MB.
Experiment, it's hard to say otherwise. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Fri Aug 08, 2008 5:05 am Post subject: |
|
|
If i use | Code: | | PSP_HEAP_SIZE_KB(-12*1024); |
then the browser doesn't crash but it says:
| Code: | | Error 0x800200D9 initing browser. |
* 800200D9 = failed to allocate the memory block
I load a bunch of images and the main fonts with IntraFont before this. |
|
| Back to top |
|
 |
DylanNIRVANA
Joined: 03 Jan 2008 Posts: 7
|
Posted: Fri Dec 05, 2008 11:38 am Post subject: |
|
|
Sorry for bump.
Ooblik the error you refer to:
0x800200D9 = failed to allocate the memory block
check over code? |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Fri Dec 05, 2008 1:36 pm Post subject: |
|
|
Audio Mechanica uses almost all the RAM, so I used the eboot launch sample
to launch a seperate browser eboot from the program menu,
and then when the broser is done, it relaunches the original eboot into the
menu, so it looks like the web browser is built in. _________________ If not actually, then potentially. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Tue Dec 09, 2008 3:01 pm Post subject: |
|
|
| Thats what I ended up doing. The browser is really slow this way though. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Dec 09, 2008 3:14 pm Post subject: |
|
|
| Ooblik wrote: | | Thats what I ended up doing. The browser is really slow this way though. |
The browser is really slow ANY way you run it. :D |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Tue Dec 09, 2008 3:22 pm Post subject: |
|
|
| You could load PSPKVM (and maybe modify it to disable its main menu, and to exit back to your eboot) and set it set to autorun Opera Mini. At least the browser would be fast. |
|
| Back to top |
|
 |
Ooblik
Joined: 10 Apr 2008 Posts: 38
|
Posted: Fri Dec 26, 2008 6:41 am Post subject: |
|
|
| I mean that it becomes laggy, not the download speed..etc. |
|
| Back to top |
|
 |
MysticWhiteDragon
Joined: 16 Feb 2006 Posts: 30
|
|
| Back to top |
|
 |
|