2016년 9월 2일 금요일

Download data uri in Chromium Android

As a nice demo website shows, web developer can save a file via data uri. I am writing to explain how data uri is saved in chromium in this post.

When we open data uri, chromium starts a new blob url request job and when it finishes reading header information, then it will notify the completion of it.

Blob is handled by storage module and data response handling is done by net and browser loader modules.

|STORAGE| --> |NET| --> |CONTENT/BROWSER/LOADER|

From code level, we can start from loader module in content browser by |ThrottlingResourceHandler::OnResponseStarted|

This function iterated pre-registered throttles to be confirmed if any specific throttle wants to handle it. For example, when we see |InterceptDownloadResourceThrottle::ProcessDownloadRequest|, HTTP or HTTPS are handled by Android specific download delegate. However, as this post focuses on data uri handling, code will be interrupted by below condition.

  if (!url.SchemeIsHTTPOrHTTPS()) {
    RecordInterceptFailureReasons(NON_HTTP_OR_HTTPS);
    return;
  }


Let's go back where I described about pre-registered throttles iteration. So suppose there is no throttle want to handle response, code will flow into next handler. e.g. |DownloadRequestCore::OnResponseStarted|

From this point, we will see bunch of asynchronous operation happened in same browser process but sometimes in different thread. In my humble opinion, this prevents system from not responding status that hurts user experience. By the way, brief code flows are:

<Download>
|DownloadResourceHandler::OnStart| --> |DownloadManagerImpl::StartDownload| --> |DownloadItemImpl::Start| --> |DownloadFile::Initialize|

<Notify download started>
|DownloadFile::Initialize| --> |DownloadController::OnDownloadStarted| -> |ChromeDownloadDelegate::OnDownloadStarted| --> |ChromeDownloadDelegate#onDownloadStarted|

I also recommend to read nice sequence diagrame.

Hope this post saves your time from debugging. Happy hacking!

(Debugging was done with 53.0.2785.0 version)

2015년 10월 13일 화요일

Gradle build error on multidex library

When you meet this kind of error:

Could not resolve com.android.support:multidex:1.0.1

 You probably have added multidex support for targets lower than Android 5.0 like:

multiDexEnabled true

Solution is to install 'Android Support Repository' in 'SDK Manager'


[1] https://developer.android.com/tools/support-library/features.html#multidex
[2] https://developer.android.com/tools/support-library/setup.html#libs-without-res

2013년 4월 21일 일요일

Disable chromium thin archive build

Find 'alink_thin' in 'tools/gyp/pylib/gyp/generator/ninja.py' file, then remove 'T' option (rcsT -> rcs). After that build again and you can observe *.a files are much bigger than before. :-)

2013년 2월 22일 금요일

I have become a WebKit committer

This is really a late note. :-)

I have become a WebKit committer since 16 Feb 2013.
I already have got required support from reviewers last October then have system permission few days before.

Thanks WebKit!

2012년 11월 23일 금요일

[work-around] Using proxy on GTK MiniBrowser

Caveat : This code is not contributable!! Just for local test! :-)

Just export http_proxy on your machine.(bashrc, profile, environment .. whatever)

    diff --git a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp
    index f17ac6c..bb93511 100644
    --- a/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp
    +++ b/Source/WebKit2/WebProcess/gtk/WebProcessMainGtk.cpp
    @@ -71,6 +71,13 @@ WK_EXPORT int WebProcessMainGtk(int argc, char* argv[])
         g_object_set(session, SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
                      SOUP_SESSION_SSL_STRICT, FALSE, NULL);
     
    +    const char *httpProxy = g_getenv("http_proxy");
    +    if (httpProxy) {
    +        SoupURI *proxyUri = soup_uri_new(httpProxy);
    +        g_object_set(session, SOUP_SESSION_PROXY_URI, proxyUri, NULL);
    +        soup_uri_free(proxyUri);
    +    }
    +
         GOwnPtr<char> soupCacheDirectory(g_build_filename(g_get_user_cache_dir(), g_get_prgname(), NULL));
         GRefPtr<SoupCache> soupCache = adoptGRef(soup_cache_new(soupCacheDirectory.get(), SOUP_CACHE_SINGLE_USER));
         soup_session_add_feature(session, SOUP_SESSION_FEATURE(soupCache.get()));

2012년 11월 15일 목요일

[WebKit] Render code flow when you set src on img tag.

 Aside from setting value via idl interface, rendering has its own flow.

As you can see below, from the loader, RenderObject has callback for its resource change. Then, it will compare the width and height if it really has been changed and trigger setNeedsLayout with relevant value.

1   0x7fa41cac6cd8 WebCore::RenderObject::setNeedsLayout(bool, WebCore::MarkingBehavior)
2   0x7fa41d2d2c47 WebCore::RenderImage::imageDimensionsChanged(bool, WebCore::IntRect const*)
3   0x7fa41d2d2926 WebCore::RenderImage::imageChanged(void*, WebCore::IntRect const*)
4   0x7fa41d346911 WebCore::RenderObject::imageChanged(WebCore::CachedImage*, WebCore::IntRect const*)
5   0x7fa41cf80c42 WebCore::CachedImage::didAddClient(WebCore::CachedResourceClient*)
6   0x7fa41cf869e3 WebCore::CachedResource::addClient(WebCore::CachedResourceClient*)
7   0x7fa41d2d59d9 WebCore::RenderImageResource::setCachedImage(WebCore::CachedImage*)
8   0x7fa41cf2baed WebCore::ImageLoader::updateRenderer()
9   0x7fa41cf2b6a1 WebCore::ImageLoader::notifyFinished(WebCore::CachedResource*)
10  0x7fa41ccef60e WebCore::HTMLImageLoader::notifyFinished(WebCore::CachedResource*)
11  0x7fa41cf861d0 WebCore::CachedResource::checkNotify()
12  0x7fa41cf81eb9 WebCore::CachedImage::data(WTF::PassRefPtr<WebCore::ResourceBuffer>, bool)
13  0x7fa41cf48ca2 WebCore::SubresourceLoader::didFinishLoading(double)
14  0x7fa41cf43fd1 WebCore::ResourceLoader::didFinishLoading(WebCore::ResourceHandle*, double)

How to download webkitgtk-test-fonts archive when you are behind firewall.

As WebKitten, it is unfortunate that I am working behind firewall.
I don't think this is acceptable for web developers.
Anyway, I have no power to get rid of it from my surroundings :-), alternatively here I leave how we can download files, specifically those repositories are not certified.

Easy. Add '--no-check-certificate' option!

wget --no-check-certificate https://github.com/downloads/mrobinson/webkitgtk-test-fonts/webkitgtk-test-fonts-0.0.3.tar.gz

Have fun!